Tag: 按钮

跨多个控件共享事件处理程序

在用C#编写的Windows窗体应用程序中,我有一堆按钮。 当用户的鼠标hover在按钮上时,我希望按钮的边框发生变化。 目前我有以下多个实例(每个按钮的副本): private void btnStopServer_MouseEnter(object sender, EventArgs e) { oldColor = btnStopServer.FlatAppearance.BorderColor; btnStopServer.FlatAppearance.BorderColor = mouseOverColor; } private void btnStopServer_MouseLeave(object sender, EventArgs e) { btnStopServer.FlatAppearance.BorderColor = oldColor; } 由于我有很多按钮,更改按钮边框颜色的代码占用了大量空间。 有没有更简单的方法可以做到这一点?

ASP.NET按钮未在单击事件上触发

我是Asp.net的新手,我的问题可能不那么专业。 我在我的asp.net Web表单项目中使用Udemy.com的设计。 我将udemy的页眉和页脚放在udemy页中。 但是,当我向m web表单中的一个添加按钮时,click事件将不会触发。 protected void Button1_Click1(object sender, EventArgs e) { Page.Title = “Sample Text”; } 为了解决这个问题,我从我的页面中删除了所有脚本。 我还尝试将CausesValidation设置为False。 但没有任何帮助。 你能帮我解决这个问题吗? 更新 我在我的代码中添加了OnClick事件。 但我仍然面临这个问题。

按钮的动画发光效果 – C#Windows窗体

我想按下按钮时将动画应用到我的按钮。 在WPF中,我可以使用Storyboard和触发器来创建动画。 这是一个例子: 和: Windows窗体没有Storyboard和触发器。 如何在Windows窗体中制作流畅的动画? 这是我的Windows窗体代码: void DelayTime() { timer = new Timer(); timer.Interval = (int)System.TimeSpan.FromSeconds(this.DelayTime).TotalMilliseconds; timer.Tick += (s, es) => { this.mouseover = false; this.Cursor = Cursors.Hand; this.Enabled = true; }; timer.Start(); } protected override void OnMouseDown(MouseEventArgs mevent) { base.OnMouseDown(mevent); mouseover = true; this.Enabled = false; DelayTime(); } protected override void OnPaint(PaintEventArgs e) […]

如何在Click事件中设置canvas ZIndex WPF按钮控件?

我有三个按钮一个接一个地躺着。 我想显示所有按钮的顶部,我点击。 所以我在XAML Code中设置了canvas ZIndex。 但我想在Code Behind中做到这一点。 我的XAML输出和代码 – 我的XAML输出和代码(检查ZIndex的更改方式) – 我如何在Click事件中更改WPF按钮控件中的Canvas.ZIndex属性?

WinForms TabControl – 添加新标签按钮(+)

如何在Windows窗体应用程序中向TabControl添加+按钮。 这是WPF的答案。 但是我想在WinForms应用程序中使用它?

如何以编程方式将按钮添加到gridview并将其分配给特定的代码隐藏function?

在运行时我正在创建一个DataTable并使用嵌套的for循环来填充表。 此表我稍后将DataSource指定给gridview,并在RowDataBound上指定每个单元格的值。 我想知道如何给每个单元格一个按钮并将该按钮分配给代码隐藏function。 我将有12个按钮,每个按钮将包含不同的值。 如果它们都使用某种存储特定于单元格的值的事件调用相同的函数,我更愿意。 这是创建表的代码: protected void GridViewDice_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable diceTable = _gm.GetDice(_gameId); for (int i = 0; i -1) { /*This is where I’d like to add the button*/ //e.Row.Cells[i].Controls.Add(new Button); //e.Row.Cells[i].Controls[0].Text = specific value from below //This is where the specific value gets input e.Row.Cells[i].Text = diceTable.Rows[e.Row.RowIndex][i].ToString(); } } […]

如何通过单击ASP.NET网格视图中的行中的按钮来获取行数据

我在ASP.NET Web应用程序中有一个GridView ,其中我在每行中添加了两个按钮: 现在我如何通过单击行中的编辑按钮来从gridview获取行数据?

以编程方式更改WPF中的按钮图标

我目前有一个按钮,上面有一个图标/图像。 我在XAML中配置了按钮和图像: 我需要能够以编程方式将此按钮的图像从playIcon更改为stopIcon。 我怎样才能做到这一点?

如何动态添加按钮到我的表单?

当我点击button1时,我想在表单上创建10个按钮。 下面的代码没有错误,但它也不起作用。 private void button1_Click(object sender, EventArgs e) { List buttons = new List(); for (int i = 0; i < buttons.Capacity; i++) { this.Controls.Add(buttons[i]); } }

C#如何通过WebBrowser自动单击按钮

点击页面的Html代码是: 我尝试使用此代码进行点击: webBrowser1.Document.GetElementById(“publishButton-ns”).InvokeMember(“click”); 但是没找到按钮。