1.首先到GridControl控件设计里设置属性Repository (In-place EditorRepository) 如下图(CheckEdit可以不添加,这是本人根据自己需求添加的):
主要设置两个两个属性 NullText,Name
2.绑定数据
关键代码如下:
DataTable dt = dbHelp.GetDataSql("select TS_NO,TS_NAME ,TS_LONGITUDE,TS_LATITUDE,TS_RANK from dbo.LPTE_TS");
grStation.DataSource = null;
gvStation.Columns.Clear();
grStation.DataSource = dt;
gvStation.Columns["TS_NO"].Visible = false;
gvStation.Columns["TS_NAME"].Visible = true;
gvStation.Columns["TS_NAME"].Caption = "名称";
gvStation.Columns["TS_NAME"].VisibleIndex = 1;
gvStation.Columns["TS_RANK"].Visible = true;
gvStation.Columns["TS_RANK"].Caption = "等级";
gvStation.Columns["TS_RANK"].VisibleIndex = 2;
gvS