zoukankan      html  css  js  c++  java
  • DevExpress中XtraEditors.RadioGroup 控件如何保存获取选中的值及读取数据库中的值

    场景部署设计如下:

    1.数据库库字段设计设计如下:

    数据库中有一个User(用户表), 里面有一个Status字段 bigint类型 

    代表用户状态 1=启用  Active  2=禁用  Inactive

    2.实体类设计如下:

     [Serializable]
        public class UserInfo
        {
            
            private long status = 1;
            /// <summary>
            /// 用户状态。
            /// 1=启用 Active
            /// 2=禁用 Inactive
            /// </summary>
            public long Status
            {
                get { return status; }
                set { status = value; }
            }
              }

    3.界面设计处理(保存选中的数据或获取数据库数据)
      1)获取数据库中的数据

    radioGroupStatus.SelectedIndex = (int)userInfo.Status-1;

    备注:radioGroupStatus是RadioGroup 控件name ;userInfo是实体类的操作对象 ;radioGroupStatus.Properties.Item中的值value分别是0,1

      2)保存选取中的值

    userInfo.Status = radioGroupStatus.SelectedIndex+1;

    杂记:GridView.CustomDrawCell事件可以对GridView展示的列进行处理.

    gridView1.CustomDrawCell += gridView1_CustomDrawCell;
    
    void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
            {
                if (e.Column.FieldName == "Status")
                {
                    switch (e.CellValue.ToInt())
                    {
                        case 1: e.DisplayText = "启用"; break;
                        case 2: e.DisplayText = "禁用"; break;
    
                    }
                }
                          
            }
  • 相关阅读:
    kernel makefile分析 之include路径分析
    python模块,包,安装
    python 资源
    Python版QQ群发消息
    marvell 88f6282 工程包制作
    CPU : 二级缓存容量
    编译多个文件到内核模块
    展布频谱(Spread Spectrum, SS)
    编程练习 链表题目反序,合并
    汇编语言基础之七 框架指针的省略(FPO)
  • 原文地址:https://www.cnblogs.com/lqsilly/p/sillysoft.html
Copyright © 2011-2022 走看看