linq to xml 我需要做什么才能绑定到 gridview?
如何设置 VSTUDIO 以便将 linq to xml 查询结果绑定到 gridview 而不是写入控制台?
namespace TestCFG
{ 班级计划 { 公共类 XAxisCalib {
static void Main(string[] args)
{
{
string[] fileEntries = Directory.GetFiles(@"c:\Sciclone UAC", "*.cfg*");
foreach (string fileName in fileEntries)
{
XDocument doc = XDocument.Load(fileName);
var query = from x in doc.Descendants("XAxisCalib")
select new
{
MaxChild = x.Descendants("Max"),
MinChild = x.Descendants("Min")
};
foreach (var x in query)
{
foreach (var nextLevel in x.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in x.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
var query2 = from y in doc.Descendants("YAxisCalib")
select new
{
MaxChild = y.Descendants("Max"),
MinChild = y.Descendants("Min")
};
foreach (var y in query2)
{
foreach (var nextLevel in y.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in y.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
var query3 = from z in doc.Descendants("ZAxisCalib")
select new
{
MaxChild = z.Descendants("Max"),
MinChild = z.Descendants("Min")
};
foreach (var z in query3)
{
foreach (var nextLevel in z.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in z.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
}
}
}
}
}
}
}
}
How do I setup VSTUDIO in order to bind my linq to xml query results to gridview rather than writing to console?
namespace TestCFG
{
class Program
{
public class XAxisCalib
{
static void Main(string[] args)
{
{
string[] fileEntries = Directory.GetFiles(@"c:\Sciclone UAC", "*.cfg*");
foreach (string fileName in fileEntries)
{
XDocument doc = XDocument.Load(fileName);
var query = from x in doc.Descendants("XAxisCalib")
select new
{
MaxChild = x.Descendants("Max"),
MinChild = x.Descendants("Min")
};
foreach (var x in query)
{
foreach (var nextLevel in x.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in x.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
var query2 = from y in doc.Descendants("YAxisCalib")
select new
{
MaxChild = y.Descendants("Max"),
MinChild = y.Descendants("Min")
};
foreach (var y in query2)
{
foreach (var nextLevel in y.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in y.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
var query3 = from z in doc.Descendants("ZAxisCalib")
select new
{
MaxChild = z.Descendants("Max"),
MinChild = z.Descendants("Min")
};
foreach (var z in query3)
{
foreach (var nextLevel in z.MaxChild)
{
Console.WriteLine("" + nextLevel.Value);
}
foreach (var nextLevel in z.MinChild)
{
Console.WriteLine("" + nextLevel.Value + "\n");
}
}
}
}
}
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地执行一些操作,例如
YourDataGrid
是一个虚构的对象,应将其替换为您在 Windows 窗体应用程序或 WPF 应用程序中创建的 DataGrid 的任何名称(尽管这更复杂)You can simply do something such as
YourDataGrid
is a fictitious object that should be replaced with whatever name you give the DataGrid that you create in a Windows Form application or a WPF application (though this is more complex)