如何在按钮点击甚至处理程序之间切换[关闭](How to alternate between button click even handlers [closed])

系统教程 行业动态 更新时间:2024-06-14 16:57:39
如何在按钮点击甚至处理程序之间切换[关闭](How to alternate between button click even handlers [closed])

我正在创建一个添加/编辑用户的桌面应用程序。 这两个函数将使用相同的输入,但每个函数将需要不同的点击处理程序来更新数据并将新数据插入我的数据库但是我想使用相同的按钮

他们是否可以将不同的点击处理程序分配到同一个按钮?

I am creating a desktop application that adds/edits users. Both functions will use the same inputs however each function will require different click handlers to update data and to insert new data into my database however I want to utilize the same buttons

Is their a way I can assign different click handlers to the same button?

最满意答案

是的你可以,

//Register both handlers within constructor button1.Click += new EventHandler(InsertOperationHandler); button1.Click += new EventHandler(UpdateOperationHandler);

-

private void InsertOperationHandler(object sender, EventArgs e) { } private void UpdateOperationHandler(object sender, EventArgs e) { }

Yes you can,

//Register both handlers within constructor button1.Click += new EventHandler(InsertOperationHandler); button1.Click += new EventHandler(UpdateOperationHandler);

-

private void InsertOperationHandler(object sender, EventArgs e) { } private void UpdateOperationHandler(object sender, EventArgs e) { }

更多推荐

本文发布于:2023-04-13 11:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/3056a4d50cd691dfae06d44963b08b92.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   程序   如何在   alternate   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!