zoukankan      html  css  js  c++  java
  • Dev GridControl 和chartControl、SplitterControl 简单操作

    此案例是关于Dev GridControl 合chartControl 控件的显示数据,

    GridControl 控件:

    1.绑定IList<T> 对象,

    2.实现全选,

    1. //点击全选按钮取得方法   
    2. private void checkEdit1_CheckedChanged(object sender, EventArgs e)  
    3.         {  
    4.             try  
    5.             {  
    6.                 listP = gridControl1.DataSource as IList<Perf_cell_g>;  
    7.                 for (int i = 0; i < listP.Count; i++)  
    8.                 {  
    9.                     Perf_cell_g p = listP[i] as Perf_cell_g;                    
    10.                     p.CHECK = checkEdit1.Checked;                     
    11.                 }  
    12.                 gridControl1.RefreshDataSource();  
    13.             }  
    14.             catch (Exception)  
    15.             {  
    16.   
    17.             }  
    18.         }  

    3.删除选择的多行,

    1. /// <summary>   
    2.        /// 删除选中行的数据   
    3.        /// </summary>   
    4.        /// <param name="sender"></param>   
    5.        /// <param name="e"></param>   
    6.        private void simpleButton2_Click(object sender, EventArgs e)  
    7.        {  
    8.            List<string> selectedRows = new List<string>();  
    9.        
    10.            listP = gridControl1.DataSource as IList<Perf_cell_g>;  
    11.            for (int i = 0; i < listP.Count; i++)  
    12.            {  
    13.                Perf_cell_g p = listP[i] as Perf_cell_g;  
    14.   
    15.              if (p.CHECK.ToString().ToLower() == "true")  
    16.              {  
    17.                  selectedRows.Add(p.CHECK.ToString());  
    18.              }  
    19.   
    20.            }  
    21.            if (DialogResult.OK == MessageBox.Show("确认删除此模板?""提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))  
    22.            {  
    23.                MessageBox.Show(string.Format("选中了{0}个需要删除的数据", selectedRows.Count));  
    24.            }  
    25.            //删除选中的行   
    26.        }  

    4.在GridControl 最下行显示某列所有数据计算总和、某列下行显示总记录数,

    1. //设置属性     
    2.   
    3. this.gridColumn2.SummaryItem.DisplayFormat = "总记录数={0}";  
    4.             this.gridColumn2.SummaryItem.FieldName = "CHINA_NAME";  
    5.             this.gridColumn2.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Count;  

    5.某列中对于数据>3300 该列特殊颜色显示,

    1. 方法一(写方法):  
    2. /// <summary>   
    3.         /// 行单元格的样式   对于Ci列如果改列值大于3300 高亮显示该列   
    4.         /// </summary>   
    5.         /// <param name="sender"></param>   
    6.         /// <param name="e"></param>   
    7.         private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)  
    8.         {  
    9.             try  
    10.             {      
    11.                 if (e.Column.FieldName != "Ci")  
    12.                     return;  
    13.   
    14.                 string ciV = gridView1.GetListSourceRowCellValue(e.RowHandle, e.Column.FieldName).ToString(); //获取ci 列的值   
    15.                 if (ciV.Trim() != "")  
    16.                 {                     
    17.                     if (Convert.ToInt32(ciV) > 3300)  
    18.                     {  
    19.                         DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appType1);                          
    20.                     }    
    21.                 }  
    22.             }  
    23.             catch { }  
    24.         }  
    25.   
    26. 方法二(属性设置GridView1 属性中添加):  
    27. styleFormatCondition1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));  
    28.             styleFormatCondition1.Appearance.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));  
    29.             styleFormatCondition1.Appearance.ForeColor = System.Drawing.Color.Black;  
    30.             styleFormatCondition1.Appearance.GradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;  
    31.             styleFormatCondition1.Appearance.Options.UseBackColor = true;  
    32.             styleFormatCondition1.Appearance.Options.UseForeColor = true;  
    33.             styleFormatCondition1.Column = this.gridColumn4;  
    34.             styleFormatCondition1.Condition = DevExpress.XtraGrid.FormatConditionEnum.GreaterOrEqual;  
    35.             styleFormatCondition1.Value1 = "3300";  
    36.             this.gridView1.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] {  
    37.             styleFormatCondition1});  

    6.隐藏GridControl 表最上行的英文字符

    7.设置GridControl 中除了check 列之外的列不能编辑

    chartControl 控件:

    1.点击GridControl 该行某列下表显示该列的线性图形(chartControl)

    2.根据GridControl 选择行某列的值,图的标题相应改变为该列的值

    SplitterControl 用于分割两个控件 // // splitterControl1 // this.splitterControl1.Dock = System.Windows.Forms.DockStyle.Bottom; this.splitterControl1.Location = new System.Drawing.Point(0, 336); this.splitterControl1.Name = "splitterControl1"; this.splitterControl1.Size = new System.Drawing.Size(1028, 6); this.splitterControl1.TabIndex = 1; this.splitterControl1.TabStop = false; 效果图片:

  • 相关阅读:
    线上服务被干爆了,竟然是日志的锅!!
    求你了,不要再在对外接口中使用枚举类型了!
    深坑啊!同一个Spring AOP的坑,我一天踩了两次!
    自定义注解!绝对是程序员装逼的利器!!
    20.flask博客项目实战十五之蓝图
    19.flask博客项目实战十四之 Ajax
    18.flask博客项目实战十三之国际化和本地化
    17.flask博客项目实战十二之处理日期和时间
    16.flask博客项目实战十一之Bootstrap美化站点
    15.flask博客项目实战十之发送邮件
  • 原文地址:https://www.cnblogs.com/peter-Blog/p/3334216.html
Copyright © 2011-2022 走看看