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控件的 ...
随机推荐
- java中Collections.sort排序详解
Comparator是个接口,可重写compare()及equals()这两个方法,用于比价功能:如果是null的话,就是使用元素的默认顺序,如a,b,c,d,e,f,g,就是a,b,c,d,e,f, ...
- 《Git教程-廖雪峰》学习笔记
一.创建版本库 ①初始化一个Git仓库:git init ②添加文件到Git仓库:1.git add<file> ; 2.git commit 二.时光机穿梭 ①查看工作区状态,文件是否 ...
- SQL SERVER数据库备份时出现“操作系统错误5(拒绝访问)。BACKUP DATABASE 正在异常终止。”错误的解决办法
一般备份文件选择的目录为磁盘根目录或备份所选分区未授予sqlserver用户读写权限时会出现此错误. 解决办法就是给sqlserver用户授予权限: 选择要备份的文件夹 ,右键-->属性--&g ...
- Python开发程序:RPC异步执行命令(RabbitMQ双向通信)
RPC异步执行命令 需求: 利用RibbitMQ进行数据交互 可以对多台服务器进行操作 执行命令后不等待命令的执行结果,而是直接让输入下一条命令,结果出来后自动打印 实现异步操作 不懂rpc的请移步h ...
- 原生node的header
首先引入http模块 获取http.ServerResponse对象的方式,1.http.createServer(function(req,res){}) 其中res是http.ServerResp ...
- jsp页面常用控件
1.点击按钮返回 上一页: <input type="submit" value="返回" onclick="javascript :histo ...
- The prefix "util" for element "util:list" is not bound.
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4. ...
- hibernate 多表查询
Hibernate主要支持两种查询方式:HQL查询和Criteria查询.前者应用较为广发,后者也只是调用封装好的接口. 现在有一个问题,就是实现多表连接查询,且查询结果集不与任何一个实体类对应,怎么 ...
- Excel标题与索引的对应关系
/// <summary> /// 返回对应标题的索引 /// </summary> /// <param name="columnTitle"> ...
- 彻底卸载Oracle
彻底卸载Oracle 用Oracle自带的卸载程序不能从根本上卸载Oracle,从而为下次的安装留下隐患,那么怎么才能完全卸载Oracle呢?那就是直接注册表清除,步骤如下: 1. 开始->设置 ...