zoukankan      html  css  js  c++  java
  • Datagridview ComboboxCell选中项变化时触发事件

    private void Form1_Load(object sender, EventArgs e)
    {
        List<string> list = new List<string>();
        list.Add("1");
        list.Add("2");
        list.Add("3");
        dgv_cb.DataSource = list;
    }
    
    // Save the row index
    int RowIndex;
    
    private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
        RowIndex = dataGridView1.CurrentCell.RowIndex;
        if (dataGridView1.CurrentCell.ColumnIndex == 0)
        {
            ComboBox comboBox = e.Control as ComboBox;
            comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
        }
    }
    
    void comboBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Set the value of column "dgv_txt"
        dataGridView1.Rows[RowIndex].Cells[1].Value = ((ComboBox)sender).Text;
    }

    触发事件,修改”dgv-txt“中的值,

  • 相关阅读:
    markdown常用语法
    利用 js-xlsx 实现选择 Excel 文件在页面显示
    HTML中meta标签
    wxpy模块
    Python基础(3)
    Python基础(2)
    Python基础(1)
    Python之递归锁与互斥锁
    Python进程与线程
    Docker
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10369895.html
Copyright © 2011-2022 走看看