1、显示行号
superGridControl1.PrimaryGrid.ShowRowGridIndex = true;
2、允许调整行头的宽度
superGridControl1.PrimaryGrid.AllowRowHeaderResize = true;
3、不允许显示行头
superGridControl1.PrimaryGrid.ShowRowHeaders = false;
4、让列头显示筛选图标
superGridControl1.PrimaryGrid.EnableFiltering = true;
superGridControl1.PrimaryGrid.EnableColumnFiltering = true;
5、在列头出显示图标
.gridColumn1.HeaderStyles.Default.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image2")));
6、当鼠标移动某个列的单元格上显示图标
this.gridColumn4.CellStyles.MouseOver.Image = global::HRMS.Properties.Resources.BugUp;
this.gridColumn4.CellStyles.MouseOver.ImageAlignment = DevComponents.DotNetBar.SuperGrid.Style.Alignment.MiddleRight;
this.gridColumn4.CellStyles.SelectedMouseOver.Image = global::HRMS.Properties.Resources.BugUp;
this.gridColumn4.CellStyles.SelectedMouseOver.ImageAlignment = DevComponents.DotNetBar.SuperGrid.Style.Alignment.MiddleRight; //如果该行设置了ReadOnly
this.gridColumn4.CellStyles.ReadOnlyMouseOver.Image = global::HRMS.Properties.Resources.BugUp;
this.gridColumn4.CellStyles.ReadOnlySelectedMouseOver.Image = global::HRMS.Properties.Resources.BugUp;
7、如何当单元格可以选择指定值
//先定义一个类
internal class FragrantComboBox : GridComboBoxExEditControl
{
public FragrantComboBox(IEnumerable orderArray)
{
DataSource = orderArray;
}
} //让后在窗体构造方法中的InitializeComponent后面添加代码
string[] orderArray = { "Asterids", "Eudicots", "Rosids" };
superGridControl1.PrimaryGrid.Columns["bm"].EditorType = typeof(FragrantComboBox);
superGridControl1.PrimaryGrid.Columns["bm"].EditorParams = new object[] { orderArray };
8、显示子表
//在load方法中加载数据
private void MainForm_Load(object sender, EventArgs e)
{ SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=192.168.0.133;database=analyse_ipos;user id=sa;password=sa";
conn.Open(); DataSet set = new DataSet(); new SqlDataAdapter("select zddm,dz,sj from ipos_zdjbb", conn).Fill(set, "zdjbb"); superGridControl1.PrimaryGrid.DataSource = set;
superGridControl1.PrimaryGrid.DataMember = "zdjbb"; new SqlDataAdapter("select top 1000 id,djbh,zddm,sl,je,yyrq from ipos_qtlsd",conn).Fill(set,"qtlsd");
new SqlDataAdapter("select q.id,q.djbh,spdm,sptm,m.sl,m.je from ipos_qtlsdmx m inner join (select top 1000 id,djbh from ipos_qtlsd) q on m.dj_id=q.id", conn).Fill(set, "qtlsdmx");
set.Relations.Add("", set.Tables["zdjbb"].Columns["zddm"], set.Tables["qtlsd"].Columns["zddm"]);
set.Relations.Add("", set.Tables["qtlsd"].Columns["id"], set.Tables["qtlsdmx"].Columns["id"]);
conn.Close(); } //数据绑定完成事件
private void superGridControl1_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)
{ GridPanel panel = e.GridPanel;
//显示行号
panel.ShowRowGridIndex = true;
if (panel.DataMember == "qtlsdmx")
{
double count = ;
foreach (GridElement item in panel.Rows)
{
GridRow row = item as GridRow;
count += Convert.ToDouble(row["je"].Value);
} panel.Footer.Text = string.Format("<font size='9' famaly='宋体'>总金额:<font color='Green'>{0}</font></font>", count);
}
}
9、设置行号的起始值(默认值为0)
superGridControl1.PrimaryGrid.RowHeaderIndexOffset = ;
10、设置展开和收缩图标
this.superGridControl1.PrimaryGrid.CollapseImage = global::HRMS.Properties.Resources.BugRight;
this.superGridControl1.PrimaryGrid.ExpandImage = global::HRMS.Properties.Resources.BugUp;
11、显示Filter
this.superGridControl1.PrimaryGrid.Filter.Visible = true;
12、允许按列分组
this.superGridControl1.PrimaryGrid.GroupByRow.Visible = true;
13、使用分组
GridPanel panel = superGridControl1.PrimaryGrid;
panel.SetGroup(panel.Columns["Period"]);