在特定条件下隐藏/显示按钮 [英] Hiding / displaying buttons under certain conditions

查看:41
本文介绍了在特定条件下隐藏/显示按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

form1 上有带有此代码的 buttons.有一个按钮可以转到磁盘分区C"、D"、E"、F"等.如果计算机有这样的磁盘分区 - button 是可见的,否则 button 是隐藏的.怎么做?

On the form1 there are buttons with this code. There is a button to go to the disk partition "C", "D", "E", "F" and so on. If the computer has such a disk partition - the button is visible else the button is hidden. How to do it?

private void button10_Click(object sender, EventArgs e)
        {
            webBrowser1.Navigate(@"C:\");
        }

推荐答案

button10_Click() 这是你的Form的按钮事件,里面可以这样写

button10_Click() this is a button event of your Form, inside that you can write like this

if(System.IO.DriveInfo.Contains == yourDrive)
{
    button10.visible = true;
}
else 
{
    button10.visible = false;
}

这篇关于在特定条件下隐藏/显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆