如何获取列表打开Windows窗体名称 [英] how to get list open windows forms name
本文介绍了如何获取列表打开Windows窗体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在列表中显示已打开的表单名称列表。该怎么办...
解决方案
试试这个:
列表与LT;串GT; elements = new List< string>();
foreach (表单项 in Application.OpenForms)
elements.Add(item .Name);
使用Linq:// < span class =code-comment> required
using System.Collections.Generic;
使用 System.Linq;
// 方法中的某处......
List< string> OpenFormNameList = Application.OpenForms.Cast< Form>()。选择(f = > f.Name)。ToList();
< / string > 跨度>
i need to display list of opened forms name in list. how to do it...
解决方案
try this:
List<string> elements= new List<string>(); foreach (Form item in Application.OpenForms) elements.Add(item.Name );
Using Linq://required using System.Collections.Generic; using System.Linq; // somewhere in a method ... List<string> OpenFormNameList = Application.OpenForms.Cast<Form>().Select(f => f.Name).ToList(); </string>
这篇关于如何获取列表打开Windows窗体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文