Winforms 如何在VC++;2010

Winforms 如何在VC++;2010,winforms,visual-c++,Winforms,Visual C++,我需要找出表单上控件的类型。它是TreeView、GroupBox还是标签 我正在使用 for(int i=0;i!=Properties->Controls->Count;i++) { Control^ Current_Control=Properties->Controls->default[i]; } 对不起,我的英语不好您可以遍历表单上的控件,并使用TypeOf和GetType: Public Sub ClearAll(ByVal frm As C

我需要找出表单上控件的类型。它是TreeView、GroupBox还是标签

我正在使用

for(int i=0;i!=Properties->Controls->Count;i++)
{
   Control^ Current_Control=Properties->Controls->default[i];
}

对不起,我的英语不好

您可以遍历表单上的控件,并使用TypeOf和GetType:

    Public Sub ClearAll(ByVal frm As Control)
    For Each C As Control In frm.Controls
        Dim Ctl As Control = C
        If ControlList.Contains(Ctl.GetType) Then
            ClearAll(Ctl)
        ElseIf (TypeOf Ctl Is TextBox) Then
            Ctl.Text = ""
        End If   
    Next
   End Sub
这将搜索文本框并清除文本。如果点击groupbox或其他容器,它将清除其中的所有文本框。

array^Control\u Type\u Name=Properties->Controls->default[i]->GetType()->FullName->Split('.');字符串^Control\U Type=控制类型名称[控制类型名称->长度-1];可能重复的