how to find a winform by name in VS project?
-
Hello,everyone! I want to find a winform by its name in my project. At first, I thougt it could return the specific form with codes like below:
for each iForm as Form in XXX
'do someting
return iForm
nextIs this right or not? If right, what's the collection included forms of project? If wrong, what should I do? Would you give me some suggestions or demo? Thanks!
-
Hello,everyone! I want to find a winform by its name in my project. At first, I thougt it could return the specific form with codes like below:
for each iForm as Form in XXX
'do someting
return iForm
nextIs this right or not? If right, what's the collection included forms of project? If wrong, what should I do? Would you give me some suggestions or demo? Thanks!
if it is a visible form belonging to your own process, iterate the
Application.OpenForms
collection. Otherwise, you will need to enumerate all the Windows windows using the EnumWindows[^] function (in user32.dll) using P/Invoke. :)Luc Pattyn [My Articles] Nil Volentibus Arduum