20161014006 DataGridView Combobox 数据绑定与传值
//Combobox
private void T_Form_CY_CBD_D_CurrentCellChanged(object sender, EventArgs e)
{
DataGridViewCell CurrnetCell = T_Form_CY_CBD_D.CurrentCell;
T_Form_CY_CBD_D.Columns["DFWorkRate"].ReadOnly = true;
if (CurrnetCell != null && CurrnetCell.OwningColumn.Name == "DFDevice")
{
try
{
Rectangle rect = T_Form_CY_CBD_D.GetCellDisplayRectangle(T_Form_CY_CBD_D.CurrentCell.ColumnIndex, T_Form_CY_CBD_D.CurrentCell.RowIndex, false);
string sexValue = T_Form_CY_CBD_D.CurrentCell.Value.ToString();
string str_sql = " Select [FMachineType],[FMPWorkRate] FROM [PLM].[dbo].[T_Form_CY_RateOfWork_D] ";
DataTable dt2 = PLMDAL.DBHelper.ExecSql(str_sql);
DataGridViewComboBoxColumn cbo = (DataGridViewComboBoxColumn)T_Form_CY_CBD_D.Columns["DFDevice"];
cbo.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
cbo.DataSource = dt2;
cbo.DisplayMember = "FMachineType";
cbo.ValueMember = "FMachineType";
if (CurrnetCell.Value.ToString().Trim() != "")
{
DataRow[] dr = dt2.Select("FMachineType = '" + CurrnetCell.Value.ToString().Trim() + "' ");
//MessageBox.Show(dr[0].ItemArray[1].ToString().Trim());
T_Form_CY_CBD_D.CurrentRow.Cells["DFWorkRate"].Value = dr[0].ItemArray[1].ToString().Trim();
}
//string selectValue = (string)(T_Form_CY_CBD_D.CurrentCell as DataGridViewComboBoxCell).Value;//取得所选值的key即绑定ValueMember的值。
//MessageBox.Show("" + selectValue.ToString() + "");
//MessageBox.Show(CurrnetCell.Value.ToString());
//
////DataGridViewComboBoxCell DgvCell = T_Form_CY_CBD_D.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell;
//DataGridViewComboBoxCell DgvCell = T_Form_CY_CBD_D.CurrentCell as DataGridViewComboBoxCell;
//DgvCell.DataSource = dt2.Rows[0][0].ToString();
////DgvCell.DisplayMember = "MeasureName";
////DgvCell.ValueMember = "MeasureId";
//string selectValue = (string)(T_Form_CY_CBD_D.CurrentCell as DataGridViewComboBoxCell).Value;//取得所选值的key即绑定ValueMember的值。
//MessageBox.Show("" + selectValue.ToString() + "");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
20161014006 DataGridView Combobox 数据绑定与传值的更多相关文章
- C# WinForm 中ComboBox数据绑定的问题 (转)
来自:http://blog.sina.com.cn/s/blog_5fb9e26301013wga.html C# WinForm 中ComboBox数据绑定的问题 怎样让WinForm中的Comb ...
- combobox数据绑定
jquery easyui datagrid 可编辑行 combobox数据绑定问题 将带有参数的url地址赋值给变量,然后将变量赋值给url <script type="text/j ...
- WPF Combobox数据绑定 Binding
combobox数据绑定List链表集合区分显示值与选择的值 整体效果: 根据combobox选择情况分别打印选取值与显示值 代码: Windows窗体: <Window x:Class=&qu ...
- C# 控件,MenuStrip,statusStrip,contextMenuStrip,ImageList, Listview,MonthCalendar、DataGridView,combobox,textbox,DateTimePicker,treeview,picturebox、toolStrip,radioButton,TableLayoutPanel
一.菜单栏 1)MenuStrip 菜单栏 选择工具栏控件:menuStrip C# Menustrip控件的常用属性用法详解 C#WinForm应用程序——添加菜单栏MenuStrip] 1.通过右 ...
- WinForm DataGridView双向数据绑定
程序目标: 实现DataGridView与BindingList<T>双向绑定.用户通过DataGridView修改值后立即更新BindList对象的值,代码修改BindList后立即更新 ...
- MVVM模式WPF的ComboBox数据绑定,使用Dictionary作为数据源
ViewModel//属性定义 Dictionary<int, string> _selGroupList; /// <summary> /// 分组下拉列表 /// < ...
- WPF combobox数据绑定和数据获取
本文章仅为个人学习,如有错误之处请指正. 搭建WPF界面的时候,想用combobox构建一个下拉菜单,搜索的时候看到大多数都是大段代码,逻辑顺序不是很详细,摸索了大概,记录一下方便来者. 拖入comb ...
- DataGridView中的Combobox的应用
在WinForm中DataGridView可谓是应用比较多的数据显示控件了,DataGridView中可以应用各种控件,关于这样的文章网上 已有很多.都是实例化一个控件然后通过DataGridView ...
- C#: 数据绑定
数据绑定是分离UI和后端主逻辑程序的一种好的办法.这里总结下TextBox, Label, ComboBox, ListBox, DataGridView的数据绑定 数据绑定都是通过DB来和UI控件的 ...
随机推荐
- imx6 matrix keyboard
imx6需要添加4x4的矩阵键盘.本文记录添加方法. 参考链接 http://processors.wiki.ti.com/index.php/TI-Android-JB-PortingGuide h ...
- Python开发【十一章】:RabbitMQ队列
RabbitMQ队列 rabbitMQ是消息队列:想想之前的我们学过队列queue:threading queue(线程queue,多个线程之间进行数据交互).进程queue(父进程与子进程进行交互或 ...
- NSSet
版权声明:本文为博主原创文章,未经博主允许不得转载. 一.NSSet的创建和初始化 创建一个空的NSSet集合:+ (void)set; 用数组来创建NSSet集合:+ (id)setWithArra ...
- sql rank()函数
RANK() OVER([<partiton_by_clause>]) partition_by_clause 将from子句生成的结果集划分为应用到RANK函数的分区. Order_b ...
- python知识点总结
此知识要点,是根据学习廖雪峰phthon3.0教程总结的,所以结构基本和这个教程的结构相同. 背景知识 python是什么?(1)python是一门编程语言,意味着可以用python编写程序,完成一定 ...
- ps commad
要对系统中进程进行监测控制,查看状态,内存,CPU的使用情况,使用命令:/bin/ps (1) ps :是显示瞬间进程的状态,并不动态连续: (2) top:如果想对进 ...
- JS学习之路
前言 接触js也有四五年的时间了,对js的认识也逐渐加深,想把自己这几年学习js的经历记录一下. 总则-都是对象,都是引用 在接触js前用的比较多的是java,在刚开始接触js的时候,老实讲,我是有点 ...
- FORTRAN 90标准函数(一) (转)
符号约定: l I代表整型;R代表实型;C代表复型;CH代表字符型;S代表字符串;L代表逻辑型;A代表数组;P代表指针;T代表派生类型;AT为任意类型. l s:P表示s类型为P类型(任意kind ...
- C#利用微软库完成设备网络定位(经纬度-地址)
public delegate void OnPositionChangedEventHandle(object sender, PositionChangedEventArgs e); public ...
- c++ 解包tar
首先我们来看tar文件组成 tar中的数据都是以512字节为单位:tar由三部分组成 “头部+内容+尾部”,其中头部是512字节的头部结构,内容是存放一个文件内容的地方,最后尾部是一个512字节的全零 ...