C# 将值从Windows注册表传输到DataGridView表
我有一个应用程序,它的主窗体上有一个C# 将值从Windows注册表传输到DataGridView表,c#,.net,windows,registry,C#,.net,Windows,Registry,我有一个应用程序,它的主窗体上有一个DataGridView。应用程序的一个功能是从DataGridView读取和写入注册表。我能够写入注册表,目前正在尝试从注册表读取,但在将最终值放入表中时遇到问题 foreach (var x in Test.GetSubKeyNames()) { RegistryKey product = Test.OpenSubKey(x); //string SubKey = Convert.ToStri
DataGridView
。应用程序的一个功能是从DataGridView
读取和写入注册表。我能够写入注册表,目前正在尝试从注册表读取,但在将最终值放入表中时遇到问题
foreach (var x in Test.GetSubKeyNames())
{
RegistryKey product = Test.OpenSubKey(x);
//string SubKey = Convert.ToString(product);
Console.WriteLine("+\tKey: " + product);
//Testing
foreach (var value in product.GetValueNames())
{
Console.WriteLine("+\tValue: " + value);
string keyValue = Convert.ToString(product.GetValue(value));
//Having trouble here
StudentGridView.CurrentRow.Cells["Age"].Value = keyValue;
}
}
Console.ReadLine();
申请表有三栏——姓名、年龄、学校。注册表中有一个名为“Students”的子项,该子项中有几个学生姓名,这些姓名的年龄和学校值不同。我想获取子键名称并将其传输到DataGridView
中的Name列,然后获取年龄和学校值并将其传输到表中的相应列
foreach (var x in Test.GetSubKeyNames())
{
RegistryKey product = Test.OpenSubKey(x);
//string SubKey = Convert.ToString(product);
Console.WriteLine("+\tKey: " + product);
//Testing
foreach (var value in product.GetValueNames())
{
Console.WriteLine("+\tValue: " + value);
string keyValue = Convert.ToString(product.GetValue(value));
//Having trouble here
StudentGridView.CurrentRow.Cells["Age"].Value = keyValue;
}
}
Console.ReadLine();
您好,您可以将dataGridView绑定到注册表,而无需编写此循环,但您必须将子项转换为列表或数组,我不知道dataGridView是否接受子项。啊,我不知道您可以这么做-我如何绑定它@mehdizahraneTo要进行这样的绑定,您需要给它一个数据源,例如,一个学生列表,“list list list”,将datagridview与列表GridView1.datasource=list绑定;GridView1.DataBind();