0
我需要找出窗体上的控件类型。它是一个TreeView控件,组框或标签如何在VC++ 2010中找出窗体上控件的类型
我使用
for(int i=0;i!=Properties->Controls->Count;i++)
{
Control^ Current_Control=Properties->Controls->default[i];
}
对不起我的英语
我需要找出窗体上的控件类型。它是一个TreeView控件,组框或标签如何在VC++ 2010中找出窗体上控件的类型
我使用
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_Type_Name = Properties-> Controls-> default [i] - > GetType() - > FullName-> Split('。'); String^Control_Type = Control_Type_Name [Control_Type_Name-> Length-1]; –
Michail
可能重复的[C++/CLI-Question:是否有与C#等价的“is”关键字还是必须使用反射?](http://stackoverflow.com/questions/712845/c-cli-question-是-有-一个相当于到的-C-尖是-关键字或-DO-I-HAV) –