how to set SelectedIndex in DataGridViewComboBoxColumn?

后端 未结 7 844
慢半拍i
慢半拍i 2021-01-18 04:00

i am using a datagridview in that i am using a datagridviewcomboboxcolumn, comboboxcolumn is displaying text but the problem is i want to select the first item of comboboxco

相关标签:
7条回答
  • 2021-01-18 05:05

    something different worked for me what i did is to simply set the value of dtataGridComboBox when ever new record is added bu user with 'userAddedRow' event. For the first row I used the code in constructor.

    public partial class pt_drug : PatientDatabase1_3._5.basic_templet
    {
        public pt_drug()
        {
            InitializeComponent();
            dataGridView_drugsDM.Rows[0].Cells[0].Value = "Tablet";
        }
    
        private void dataGridView_drugsDM_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            dataGridView_drugsDM.Rows[dataGridView_drugsDM.RowCount - 1].Cells[0].Value = "Tablet";
        }
    
    
    }
    
    0 讨论(0)
提交回复
热议问题