如何在按钮点击甚至处理程序之间切换[关闭](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) { }更多推荐
发布评论