为什么,我的DevExpress.XtraGrid.GridControl不能显示数据呢?

水桶IIII 2007-05-06 11:25:37
为什么,我的DevExpress.XtraGrid.GridControl不能显示数据呢?
//
// gridControl1
//
this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill;
//
// gridControl1.EmbeddedNavigator
//
this.gridControl1.EmbeddedNavigator.Name = "";
this.gridControl1.Location = new System.Drawing.Point(3, 17);
this.gridControl1.MainView = this.gridView1;
this.gridControl1.Name = "gridControl1";
this.gridControl1.Size = new System.Drawing.Size(650, 404);
this.gridControl1.TabIndex = 1;
this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
this.gridView1});
//
// gridView1
//
this.gridView1.GridControl = this.gridControl1;
this.gridView1.Name = "gridView1";
//
// tbTools
//
this.tbTools.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tbbDelete,
this.tbbSave,
this.tbbSeparator1,
this.tbbExit});
this.tbTools.DropDownArrows = true;
this.tbTools.Location = new System.Drawing.Point(0, 0);
this.tbTools.Name = "tbTools";
this.tbTools.ShowToolTips = true;
this.tbTools.Size = new System.Drawing.Size(656, 41);
this.tbTools.TabIndex = 43;
//
// gridView1
//
this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
this.colsendCoID,
this.colsendCoName,
this.colsendCoAdd,
this.colsendPostCode});
this.gridControl1.DataSource = DbHelperSQL.Query("SELECT id, sendCoID, sendCoName, sendCoAdd, sendPostCode FROM sendCoInfor").Tables[0];
this.gridControl1.UseEmbeddedNavigator=true;
...全文
844 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
水桶IIII 2007-05-06
  • 打赏
  • 举报
回复
我加了个
this.gridView1.PopulateColumns(DbHelperSQL.Query("SELECT * FROM sendNameInfor").Tables[0]);
解决问题了,但不知道是什么原因!
现,问问,开那个属性,才可以保存编辑的内容,不会因为光标的离开而丢失数据
水桶IIII 2007-05-06
  • 打赏
  • 举报
回复
我这个不是通过Run Designer建立的列
是自己帮定的!
查过
this.gridControl1.DataSource = DbHelperSQL.Query("SELECT id, sendCoID, sendCoName, sendCoAdd, sendPostCode FROM sendCoInfor").Tables[0];

这里是有数据的,但不知道那里漏了?
cellblue 2007-05-06
  • 打赏
  • 举报
回复
你通过Run Designer建立那些列,并且排布了没有
水桶IIII 2007-05-06
  • 打赏
  • 举报
回复
to:cmHua()
有没有联系方法,想讨教更多关于DevExpress.XtraGrid控件的问题!
cmHua 2007-05-06
  • 打赏
  • 举报
回复
this.gridControl1.DataSource = DbHelperSQL.Query("SELECT id, sendCoID, sendCoName, sendCoAdd, sendPostCode FROM sendCoInfor").Tables[0];
这句只是将数据表绑定到了Grid,但并没有告诉Grid该怎么显示.其实你只要在这句后面加this.gridView1.PopulateColumns();就可以了,这句可以理解为把数据表中的所有列都显示出来.
还有,不是很明白你所说的保存编辑内容是什么意思?
如果是要将修改保存到数据表,用gridView1.UpdateCurrentRow();
如果要保存到数据库,那就要另外写更新语句了.

111,116

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧