用过Developer Express 的组件GridControl 请进
各位本人初学DeveloperExpressv2010vol1的组件GridControl时,遇到问题了现在用现实这样一个功能:在后台cs代码中创建一个表格添加到前台中。...
各位 本人初学Developer Express v2010 vol 1的组件GridControl时,遇到问题了 现在用现实这样一个功能:
在后台cs代码中创建一个表格添加到前台中。在表格中显示一个List中所有条目的名字(Name,条目中的Id不显示)。并且在表格中的数据能够在后台修改,然后能动态更新 不知道怎么实现这个功能 现在是表格数据都不能显示 我的GridControlTest程序如下
------------------------------------------------MainWindow.xaml--------------------------------------------------------
<Window x:Class="GridControlTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid">
</Grid>
</Window>
--------------------------------------------------MainWindow.xaml.cs--------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Grid;
namespace GridControlTest
{
/// <summary>
/// MainWindow.xaml 的ì?交?互£¤逻?辑-
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.getGridControl();
}
public void getGridControl()
{
List<People> peopleList = new List<People>();
People p1 = new People();
p1.Name = "ZhangSan";
p1.Id = "0";
peopleList.Add(p1);
People p2 = new People();
p2.Name = "ZhangSan";
p2.Id = "0";
peopleList.Add(p2);
GridControl gridControl = null;
gridControl = new GridControl();
GridColumn nameColumn = new GridColumn();
nameColumn.Header = "Name";
nameColumn.FieldName = "name";
gridControl.DataSource = peopleList;
gridControl.Columns.Add(nameColumn);
grid.Children.Add(gridControl);
}
}
}
补充见一楼
----------------------------------------- People.cs.cs ---------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GridControlTest
{
class People
{
private string name = "";
private string id = "";
public string Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
}
}
-------------------------------------------------------------我的问题-------------------------------------
1、 为什么不能显示数据。怎么才能显示
2、 要怎样做到动态更新 展开
在后台cs代码中创建一个表格添加到前台中。在表格中显示一个List中所有条目的名字(Name,条目中的Id不显示)。并且在表格中的数据能够在后台修改,然后能动态更新 不知道怎么实现这个功能 现在是表格数据都不能显示 我的GridControlTest程序如下
------------------------------------------------MainWindow.xaml--------------------------------------------------------
<Window x:Class="GridControlTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid">
</Grid>
</Window>
--------------------------------------------------MainWindow.xaml.cs--------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Grid;
namespace GridControlTest
{
/// <summary>
/// MainWindow.xaml 的ì?交?互£¤逻?辑-
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.getGridControl();
}
public void getGridControl()
{
List<People> peopleList = new List<People>();
People p1 = new People();
p1.Name = "ZhangSan";
p1.Id = "0";
peopleList.Add(p1);
People p2 = new People();
p2.Name = "ZhangSan";
p2.Id = "0";
peopleList.Add(p2);
GridControl gridControl = null;
gridControl = new GridControl();
GridColumn nameColumn = new GridColumn();
nameColumn.Header = "Name";
nameColumn.FieldName = "name";
gridControl.DataSource = peopleList;
gridControl.Columns.Add(nameColumn);
grid.Children.Add(gridControl);
}
}
}
补充见一楼
----------------------------------------- People.cs.cs ---------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GridControlTest
{
class People
{
private string name = "";
private string id = "";
public string Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
}
}
-------------------------------------------------------------我的问题-------------------------------------
1、 为什么不能显示数据。怎么才能显示
2、 要怎样做到动态更新 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询