本文介绍了如何使用Windows应用程序将数据绑定到C#中的SyncFusion GridControl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我受够了这个Syncfusion控件,与普通的datagridview相比,这些控件非常困难. Syncfusion GridControl中的Datapropertyname在哪里.如何将数据绑定到Grid Control.

gridControl1.ColStyles[3].DataSource = dt1;
gridControl1.ColStyles[3].DisplayMember = "bcmp_Name"; gridControl1.ColStyles[3].ValueMember = "bcmp_Id";
gridControl1.ColStyles[3].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[5].DataSource = dt2;
gridControl1.ColStyles[5].DisplayMember = "bcmp_Name";
gridControl1.ColStyles[5].ValueMember = "bcmp_Id";
gridControl1.ColStyles[5].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[7].DataSource = dt3;
gridControl1.ColStyles[7].DisplayMember = "bcmp_Name"; gridControl1.ColStyles[7].ValueMember = "bcmp_Id";
gridControl1.ColStyles[7].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[9].DataSource = dt4;
gridControl1.ColStyles[9].DisplayMember = "bcmp_Name";
gridControl1.ColStyles[9].ValueMember = "bcmp_Id";
gridControl1.ColStyles[9].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.TableStyle.DataSource = Chldtbl;

使用上述代码,我无法将其绑定,也无法进入他们的任何链接.

解决方案

如Doug所建议的,数据绑定的最佳方法是使用GridGrouping或GridDataBound控件.如果仍要使用GridControl,则建议您使用PopulateValues方法来绑定数据.请参考下面的代码片段和UG链接以获取更多详细信息.

C#:
this.gridControl1.BeginUpdate();
this.gridControl1.RowCount = this.numArrayRows;
this.gridControl1.ColCount = this.numArrayCols;



// Call PopulateValues Method to move values from a given data source (this.initArray) into the Grid Range specified.
this.gridControl1.Model.PopulateValues(GridRangeInfo.Cells(1, 1, this.numArrayRows, this.numArrayCols), this.intArray);
this.gridControl1.EndUpdate();
this.gridControl1.Refresh();

UG链接: http://help.syncfusion.com/ug/windows%20forms/grid/documents/thegridcontrolpopula.htm

还可以使用虚拟网格将数据绑定到网格.虚拟网格可以非常快速地显示大量数据.请参考下面的UG链接,以获取有关虚拟网格的更多详细信息.

UG链接: http://help.syncfusion.com/ug/windows%20forms/grid/documents/virtualgrids.htm

关于,阿尼什

i am fed up with this Syncfusion Controls, these are very difficult compared to normal datagridview. where is the Datapropertyname in Syncfusion GridControl. how to bind Data to Grid Control.

gridControl1.ColStyles[3].DataSource = dt1;
gridControl1.ColStyles[3].DisplayMember = "bcmp_Name"; gridControl1.ColStyles[3].ValueMember = "bcmp_Id";
gridControl1.ColStyles[3].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[5].DataSource = dt2;
gridControl1.ColStyles[5].DisplayMember = "bcmp_Name";
gridControl1.ColStyles[5].ValueMember = "bcmp_Id";
gridControl1.ColStyles[5].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[7].DataSource = dt3;
gridControl1.ColStyles[7].DisplayMember = "bcmp_Name"; gridControl1.ColStyles[7].ValueMember = "bcmp_Id";
gridControl1.ColStyles[7].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.ColStyles[9].DataSource = dt4;
gridControl1.ColStyles[9].DisplayMember = "bcmp_Name";
gridControl1.ColStyles[9].ValueMember = "bcmp_Id";
gridControl1.ColStyles[9].DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;
gridControl1.TableStyle.DataSource = Chldtbl;

By using the above code i am not able to bind it, i am not getting in any one of their links.

解决方案

As suggested by Doug, the best way for data binding is to use the GridGrouping or GridDataBound control. If you still want to use the GridControl then we suggest you to use the PopulateValues method for binding the data. Please refer the below code snippet and UG link for more details.

C#:
this.gridControl1.BeginUpdate();
this.gridControl1.RowCount = this.numArrayRows;
this.gridControl1.ColCount = this.numArrayCols;



// Call PopulateValues Method to move values from a given data source (this.initArray) into the Grid Range specified.
this.gridControl1.Model.PopulateValues(GridRangeInfo.Cells(1, 1, this.numArrayRows, this.numArrayCols), this.intArray);
this.gridControl1.EndUpdate();
this.gridControl1.Refresh();

UG link:http://help.syncfusion.com/ug/windows%20forms/grid/documents/thegridcontrolpopula.htm

Also you can make use of the Virtual Grid for binding data to your grid. Virtual grids can display large amounts of data extremely fast. Please refer the below UG link for more details regarding Virtual Grid.

UG Link:http://help.syncfusion.com/ug/windows%20forms/grid/documents/virtualgrids.htm

Regards,Anish

这篇关于如何使用Windows应用程序将数据绑定到C#中的SyncFusion GridControl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 13:09