【发布时间】:2020-09-15 08:29:23
【问题描述】:
我使用自定义按钮创建了单独的类,我希望在单击此“newButton”时弹出该类。 我该如何手动完成?所以如果有多个“newButtons”并且我想隐藏以前的自定义按钮 我的问题是我不知道如何寻找新按钮的位置,因为它位于自动放置它们的 flowLayout 中。
Button newButton = new Button();
newButton.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(175)))), ((int)(((byte)(241)))));
newButton.FlatAppearance.BorderSize = 2;
newButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
newButton.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
newButton.ForeColor = System.Drawing.Color.White;
newButton.Location = new System.Drawing.Point(158, 288);
newButton.Size = new System.Drawing.Size(150, 38);
newButton.UseVisualStyleBackColor = true;
newButton.Text = k.grp;
newButton.Click += (sender, e) => newButton_Click(sender, e);
if (checkinNames.Contains(newButton.Text))
{ }
else
flowLayoutPanel5.Controls.Add(newButton);
checkinNames.Add(k.grp);
【问题讨论】:
-
你使用的是什么 UI 框架?
-
Windows 窗体应用程序 .Net 框架
标签: c# winforms button location logic