C# 整理DotNetBar中SuperGridControl的一些基础属性

//控制表格只能选中单行

superGridControl1.PrimaryGrid.MultiSelect = false;

superGridControl1.PrimaryGrid.InitialSelection = RelativeSelection.Row;

//只能选中一个单元格,而不是一行单元格

superGridControl1.PrimaryGrid.SelectionGranularity =SelectionGranularity.Row;

值得一提的是,如果出不来效果,查看一下表格的属性

将Selection Granularity属性改为Row

//是否显示序列号

superGridControl1.PrimaryGrid.ShowRowHeaders = false;

//自动填满表格

superGridControl1.PrimaryGrid.ColumnAutoSizeMode = ColumnAutoSizeMode.Fill;

//允许单元格拖动成为集合组

superGridControl1.PrimaryGrid.ColumnHeader.AllowSelection = true;

superGridControl1.PrimaryGrid.GroupByRow.Visible = false;

GridPanel panel = superGridControl1.PrimaryGrid;

 

//设置表格自动展开

panel.AutoExpandSetGroup = true;

panel.SetGroup(panel.Columns["列名"]);

 

//设置表格中文字的位置居中     

superGridControl1.PrimaryGrid.DefaultVisualStyles.CellStyles.Default.Alignment= DevComponents.DotNetBar.SuperGrid.Style.Alignment.MiddleCenter;

 

//获取单元格的值

SelectedElementCollection col=this.superGridControl1.PrimaryGrid.GetSelectedRows();

List<GridCell> cells = col.GetCells();

textBoxX1.Text = cells[2].Value.ToString();

 

 

posted @ 2017-05-09 14:20  StephenCurry  阅读(1309)  评论(0编辑  收藏  举报