Control.Hide 方法
对用户隐藏控件。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Sub Hide
用法
Dim instance As Control
instance.Hide
public void Hide ()
public:
void Hide ()
public void Hide ()
public function Hide ()
备注
隐藏控件等效于将 Visible 属性设置为 false。在调用 Hide 方法之后,只要不调用 Show 方法,Visible 属性就返回 false 值。
示例
下面的代码示例在单击某按钮的同时按 Ctrl 键时隐藏该按钮。该示例要求在 Form 有一个名为 button1
的 Button。
Private Sub button1_Click(sender As Object, _
e As EventArgs) Handles button1.Click
' If the CTRL key is pressed when the
' control is clicked, hide the control.
If Control.ModifierKeys = Keys.Control Then
CType(sender, Control).Hide()
End If
End Sub
private void button1_Click(object sender, System.EventArgs e)
{
/* If the CTRL key is pressed when the
* control is clicked, hide the control. */
if(Control.ModifierKeys == Keys.Control)
{
((Control)sender).Hide();
}
}
private:
void button1_Click( Object^ sender, System::EventArgs^ /*e*/ )
{
/* If the CTRL key is pressed when the
* control is clicked, hide the control. */
if ( Control::ModifierKeys == Keys::Control )
{
(dynamic_cast<Control^>(sender))->Hide();
}
}
private void button1_Click(Object sender, System.EventArgs e)
{
/* If the CTRL key is pressed when the
control is clicked, hide the control.
*/
if (Control.get_ModifierKeys().Equals(Keys.Control)) {
((Control)sender).Hide();
}
} //button1_Click
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0