问题描述
Hot来从windown表单中的数据网格中获取所选值
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
cmb.HeaderText =安装;
cmb.Name =cmb;
cmb.MaxDropDownItems = 3;
cmb.Items.Add(预安装);
cmb.Items.Add(安装);
cmb.Items.Add(安装后);
dataGridView1.Columns.Add(cmb);
如何从datagrid中获取每行中的选定值。
i尝试过这个
string SelectedText =((System.Windows.Forms.DataGridView)(sender))。CurrentRow.Cells [Installation]。Value.ToString();
和
string SelectedText = Convert.ToString((dataGridVi ew1.Rows [0] .Cells [cmb] as DataGridViewComboBoxCell).FormattedValue.ToString());
PLease help,
Hot to get the selected value from a datagrid in a windown form applicaion
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
cmb.HeaderText = "Installation";
cmb.Name = "cmb";
cmb.MaxDropDownItems = 3;
cmb.Items.Add("Pre-Installation");
cmb.Items.Add("Installation");
cmb.Items.Add("Post-Installation");
dataGridView1.Columns.Add(cmb);
how to get the selected value in each row from datagrid .
i have tried with this
string SelectedText = ((System.Windows.Forms.DataGridView)(sender)).CurrentRow.Cells["Installation"].Value.ToString();
and
string SelectedText = Convert.ToString((dataGridView1.Rows[0].Cells["cmb"] as DataGridViewComboBoxCell).FormattedValue.ToString());
PLease help,
这篇关于如何从Windows窗体中的数据网格中获取所选的comboBox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!