本文介绍了如何从Windows窗体中的数据网格中获取所选的comboBox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 19:55