c# - 如何以编程方式单击 MessageBox 上的按钮
问题描述
我检查时有一个单选按钮,它应该给出一条消息
DialogResult click = MessageBox.Show("Would you like to convert the actual values to US Customary ?\n Clicking No changes just the unit system.", "Change Unit Systems to US Customary", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (click == DialogResult.Yes)
{
//some code
}
如何从按钮中的内部代码回答此消息是否?
解决方案
我不希望出现消息
如果您真的不想要它,那么只需在该单选按钮的检查更改时执行您的操作。
private void radioButton1_CheckedChanged(Object sender, EventArgs e)
{
//Validate to make sore it was not just deselected
if (radioButton1.Checked)
{
//Do whatever I want when the use checks this radio button
{
}
推荐阅读
- html - VBA中HTMLbody中的样式问题
- react-native - 身份验证流程本机反应
- javascript - 正则表达式隔离“分配给数字的报价
- css - 更改滚动条位置而不更改文本方向
- azure - Cosmos DB 高 RU
- cordova - 浏览器中 Keycloak 服务器的 Ionic Lab 错误(拒绝构建 Kyecloak 服务器,因为祖先违反了)
- git - VSCode + Github,没有初始化存储库按钮
- ios - 即使在正确设置属性后,iOS tableViewCell 也不会在重新加载 tableview 后更新
- node.js - 将多个氦 API 调用从设备移动到服务器端
- angular - 使用 SAML 为 Angular 实施 Azure AD SSO