各位 本人初学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、 要怎样做到动态更新
3、      最好能给出代码。谢谢

解决方案 »

  1.   

    你装了DEV之后,应该会有Demo的,你去看下Demo应该就会了。 
      

  2.   

     在界面上放一个gridControl,进入design,在columns选项卡那里添加需要显示的column,并将fieldName(好像是叫这个)填上要绑定的字段名。
    代码里加上gridControl.DataSource = XX就可以了。
      

  3.   

    你的GridControl是后台定义的,并未添加到界面上,当然不可能显示了,你必须直接到界面设计下拖个GridControl的控件到界面上布局后,然后调用那个添加的控件对其操作。