Originally, I wanted to write an article about GridControl. I found that there was a systematic explanation on the Internet. I glued it directly. I was also drunk when C BO couldn't find the reprint button.
Thank nanchuan and the original author of the article. I will always add on your basis.
The following [reprint]:
When using, drag it over, as shown below, even if it's intact:
Bind data source writes the code to build a table in the program:
Binding data code:private DataTable InitDt() { DataTable dt = new DataTable("curriculum vitae"); dt.Columns.Add("id",typeof(int)); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("sex", typeof(int)); dt.Columns.Add("address", typeof(string)); dt.Columns.Add("aihao", typeof(string)); dt.Columns.Add("photo", typeof(string)); dt.Rows.Add(new object[] { 1, "Zhang San", 1, "6 East Street", "Read a Book", "" }); dt.Rows.Add(new object[] { 1, "Wang Wu", 0, "2 West Street", "Surf the Internet,Game", "" }); dt.Rows.Add(new object[] { 1, "Li Si", 1, "3 South Street", "Surf the Internet,Window shopping", "" }); dt.Rows.Add(new object[] { 1, "Money eight", 0, "5 North Street", "Surf the Internet,Window shopping,Read a Book,Game", "" }); dt.Rows.Add(new object[] { 1, "Zhao 9", 1, "1 middle street", "Read a Book,Window shopping,Game", "" }); return dt; }
private void BindDataSource(DataTable dt) { //Bind DataTable gridControl1.DataSource = dt; }
private void BindDataSource(DataSet ds)
{
//Bind DataSet
gridControl1.DataSource = ds;
gridControl1.DataMember = "Table name";
}
class Model
{
public string col1 {get;set;}
public string col2 {get;set;}
}
private void BindDataSource(List<Model> lst)
{
//Bind List
gridControl1.DataSource = lst;
}

The following codes are common GridControl codes to help understand the GridControl hierarchy:
this.gridcontrol.MainView = this.gridView;//Here this.gridcontrol.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { this.repositoryItemCheckEdit1}); this.gridcontrol.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView); this.gridView.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] { this.gridColumn1, this.gridColumn2});//Here this.gridView.GridControl = this.gridcontrol;//And here this.gridView.Name = "gridView"; this.gridView.OptionsView.ShowColumnHeaders = false; this.gridView.OptionsView.ShowGroupPanel = false; this.gridView.OptionsView.ShowIndicator = false; this.gridColumn1.Caption = "gridColumn1"; this.gridColumn1.ColumnEdit = this.repositoryItemCheckEdit1; this.gridColumn1.FieldName = "Checked"; this.gridColumn1.Name = "gridColumn1"; this.gridColumn1.Visible = true; this.gridColumn1.VisibleIndex = 0; this.gridColumn1.Width = 20;