zoukankan      html  css  js  c++  java
  • DataGridView的特殊列

    假设DataGridView为dgv

    1、判断DataGridViewCheckBoxCell是否被选中

      DataGridViewCheckBoxCell chkcell = dgv[1,0] as DataGridViewCheckBoxCell;

      bool IsChecked = Convert.ToBoolean(chkcell.EditingCellFormattedValue);

      //注意此处获取DataGridViewCheckBoxCell是否选中的值,在DataGridView的CellContentClick事件(或者其他DataGridView事件)中应该取chkcell.EditingCellFormattedValue,而在非DataGridView事件比如说按钮Button的Click事件中,直接取chkcell.Value就可以了

      if(IsChecked)

      {

        //当前CheckBoxCell被选中

      }

    2、往DataGridViewComboBoxCell中添加不同的数据源

      

      //开始编辑单元格时填充枚举项(人员属性的枚举)
            private void dgvPersonProperty_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
            {
                try
                {
                    Wag_PersonPropertyExt.Wag_PersonPropertyExtRow pper = dgvPersonProperty.Rows[e.RowIndex].Tag as Wag_PersonPropertyExt.Wag_PersonPropertyExtRow;

                    Wag_PersonPropertyCode dsPersonPropertyCode = WageItemDistibutionMethod.GetPersonPropertyCodeByPropertyId(pper.PropertyId.ToString());

                    DataGridViewComboBoxCell cmb = dgvPersonProperty[e.ColumnIndex, e.RowIndex] as DataGridViewComboBoxCell;
                    cmb.DataSource = dsPersonPropertyCode._Wag_PersonPropertyCode;
                    cmb.DisplayMember = "CodeName";
                    cmb.ValueMember = "PropertyCodeId";
                }
                catch (System.Exception ex)
                {
                    MsgHelper.WarnMSG(ex.Message);
                }
            }

  • 相关阅读:
    eclipse
    Java SE Runtime Environment
    开源免费的LittleV GUI
    【转】 ARM Cortex-M 系列 MCU 错误追踪库 CmBacktrace
    【转】博客美化(7)推荐几个优秀的自定义博客
    【转】博客美化(6)为你的博文自动添加目录
    【转】博客美化(5)为博客或系统添加一个强大的评论系统
    【转】博客美化(4)为博客添加一个智能的文章推荐插件
    linux管理进程的链表
    连连看游戏(dfs)【华为上机题目】
  • 原文地址:https://www.cnblogs.com/LowerAI/p/1609557.html
Copyright © 2011-2022 走看看