制作一个使用鼠标创建并放置新按钮的按钮 [英] Make a Button that creates and places new Buttons with the Mouse

查看:60
本文介绍了制作一个使用鼠标创建并放置新按钮的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HELLO ANYBODY可以帮助我:

HELLO CAN ANYBODY HELP ME:

我试图在vb中创建一个非常简单的应用程序,我想制作一个Button,该按钮使用鼠标来创建和放置新的Button来放置它们.

I m trying to create a very simple application in vb, I would like to make a Button, that creates and places new Buttons using the mouse for alocating them.

还要为这个新的Buttons分配一个要自动擦除的功能,比如说一个弹出窗口并删除文本按钮.

Also assigning this new Buttons a function to be autoerased, let's say with a popup window and remove text button.

Public Class Form1

    Dim BMP As New Drawing.Bitmap(640, 480)
    Dim GFX As Graphics = Graphics.FromImage(BMP)
    Dim dynamicButton As New Button

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        GFX.FillRectangle(Brushes.White, 0, 0, PictureBox1.Width, PictureBox1.Height)
        PictureBox1.Image = BMP

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles PictureBox1.Click

        dynamicButton.Location = New Point(MousePosition.X - Me.Location.X - PictureBox1.Location.X - 28, MousePosition.Y - Me.Location.Y - PictureBox1.Location.Y - 50)
        dynamicButton.Height = 20
        dynamicButton.Width = 100
        dynamicButton.BackColor = Color.Blue
        dynamicButton.ForeColor = Color.AliceBlue
        dynamicButton.Text = "Link_1"
        dynamicButton.Name = "DynamicButton"
        dynamicButton.Font = New Font("Arial", 10)
        dynamicButton.BringToFront()
        PictureBox1.Image = BMP

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Controls.Add(dynamicButton)

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.TransparencyKey = BackColor

    End Sub

End Class

推荐答案

Luis Pozo,

Hi Luis Pozo,

此论坛讨论的是Visual Studio WPF/SL设计器,Visual Studio指导自动化工具包,开发人员文档和帮助系统以及Visual Studio编辑器.

This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

您的问题与VB开发有关,我将该线程移至相应的论坛寻求专业解答.

Your issue is related to VB development I will move this thread to corresponding forum for a professional answer.

此致

奥斯卡


这篇关于制作一个使用鼠标创建并放置新按钮的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆