博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SuperGridControl 使用小技巧
阅读量:5075 次
发布时间:2019-06-12

本文共 4013 字,大约阅读时间需要 13 分钟。

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、如何当单元格可以选择指定值

 

1 //先定义一个类 2 internal class FragrantComboBox : GridComboBoxExEditControl 3 { 4       public FragrantComboBox(IEnumerable orderArray) 5       { 6            DataSource = orderArray; 7       } 8 } 9 10 //让后在窗体构造方法中的InitializeComponent后面添加代码11 string[] orderArray = { "Asterids", "Eudicots", "Rosids" };12             superGridControl1.PrimaryGrid.Columns["bm"].EditorType = typeof(FragrantComboBox);13             superGridControl1.PrimaryGrid.Columns["bm"].EditorParams = new object[] { orderArray };
View Code

 

8、显示子表

1  //在load方法中加载数据 2 private void MainForm_Load(object sender, EventArgs e) 3  { 4  5             SqlConnection conn = new SqlConnection(); 6             conn.ConnectionString = "server=192.168.0.133;database=analyse_ipos;user id=sa;password=sa"; 7             conn.Open(); 8  9             DataSet set = new DataSet();10 11             new SqlDataAdapter("select zddm,dz,sj from ipos_zdjbb", conn).Fill(set, "zdjbb");12 13             superGridControl1.PrimaryGrid.DataSource = set;14             superGridControl1.PrimaryGrid.DataMember = "zdjbb";15 16             new SqlDataAdapter("select top 1000 id,djbh,zddm,sl,je,yyrq from ipos_qtlsd",conn).Fill(set,"qtlsd");17             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");18             set.Relations.Add("1", set.Tables["zdjbb"].Columns["zddm"], set.Tables["qtlsd"].Columns["zddm"]);19             set.Relations.Add("2", set.Tables["qtlsd"].Columns["id"], set.Tables["qtlsdmx"].Columns["id"]);20             conn.Close();21            22 }23 24  //数据绑定完成事件25         private void superGridControl1_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)26         {27             28             GridPanel panel = e.GridPanel;29             //显示行号30             panel.ShowRowGridIndex = true;31             if (panel.DataMember == "qtlsdmx")32             {33                 double count = 0;34                 foreach (GridElement item in panel.Rows)35                 {36                     GridRow row = item as GridRow;37                     count += Convert.ToDouble(row["je"].Value);38                 }39 40                 panel.Footer.Text = string.Format("总金额:{0}", count);41             }42         }

 

9、设置行号的起始值(默认值为0)

superGridControl1.PrimaryGrid.RowHeaderIndexOffset = 1;

 

10、设置展开和收缩图标

1 this.superGridControl1.PrimaryGrid.CollapseImage = global::HRMS.Properties.Resources.BugRight;2 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"]);

 

转载于:https://www.cnblogs.com/caoyc/p/4171450.html

你可能感兴趣的文章