我使用 cassia.dll 来管理终端服务器并编写简单的程序。我将获得 List 属性,但不知道如何在 Datarow 中进行动态添加。
DataTable 用于过滤。
private void btn_GetTSServers_Click(object sender, EventArgs e)
{
TSManager = new TerminalServicesManager();
ITerminalServer ITS = TSManager.GetRemoteServer("localhost");
ITS.Open();
BSource = new BindingSource();
DTable = new DataTable();
Type t = ITS.GetSessions().First().GetType();
PropertyInfo[] propinfo = t.GetProperties();
foreach (PropertyInfo prop in propinfo)
{
DTable.Columns.Add(prop.Name);
}
foreach(ITerminalServicesSession session in ITS.GetSessions())
{
DTable.Rows.Add(session.ServerName, .. .. . .. etc How make Dynamic?)
}
dataGridView1.DataSource = DTable;
}
private void button1_Click(object sender, EventArgs e)
{
(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = textBox1.Text;
}