//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 数据绑定与传值的更多相关文章

  1. C# WinForm 中ComboBox数据绑定的问题 (转)

    来自:http://blog.sina.com.cn/s/blog_5fb9e26301013wga.html C# WinForm 中ComboBox数据绑定的问题 怎样让WinForm中的Comb ...

  2. combobox数据绑定

    jquery easyui datagrid 可编辑行 combobox数据绑定问题 将带有参数的url地址赋值给变量,然后将变量赋值给url <script type="text/j ...

  3. WPF Combobox数据绑定 Binding

    combobox数据绑定List链表集合区分显示值与选择的值 整体效果: 根据combobox选择情况分别打印选取值与显示值 代码: Windows窗体: <Window x:Class=&qu ...

  4. 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.通过右 ...

  5. WinForm DataGridView双向数据绑定

    程序目标: 实现DataGridView与BindingList<T>双向绑定.用户通过DataGridView修改值后立即更新BindList对象的值,代码修改BindList后立即更新 ...

  6. MVVM模式WPF的ComboBox数据绑定,使用Dictionary作为数据源

    ViewModel//属性定义 Dictionary<int, string> _selGroupList; /// <summary> /// 分组下拉列表 /// < ...

  7. WPF combobox数据绑定和数据获取

    本文章仅为个人学习,如有错误之处请指正. 搭建WPF界面的时候,想用combobox构建一个下拉菜单,搜索的时候看到大多数都是大段代码,逻辑顺序不是很详细,摸索了大概,记录一下方便来者. 拖入comb ...

  8. DataGridView中的Combobox的应用

    在WinForm中DataGridView可谓是应用比较多的数据显示控件了,DataGridView中可以应用各种控件,关于这样的文章网上 已有很多.都是实例化一个控件然后通过DataGridView ...

  9. C#: 数据绑定

    数据绑定是分离UI和后端主逻辑程序的一种好的办法.这里总结下TextBox, Label, ComboBox, ListBox, DataGridView的数据绑定 数据绑定都是通过DB来和UI控件的 ...

随机推荐

  1. [skill] strncpy里边有两个坑

    以前的笔记,今日翻出了复看了一下,转过来. ------------------------------------ 今天发现xxxdump中使用xxx_strncpy 替换 strncpy导致的bu ...

  2. pdf.js pdfdom.js使用(转)

    开篇语: 最近工作需要做一个借款合同,公司以前的合同都是通过app端下载,然后通过本地打开pdf文件,而喜欢创新的我,心想着为什么不能在线H5预览,正是这个想法,说干就干,实践过程总是艰难的,折腾了3 ...

  3. Photosohp 2017 已经发布!(下载地址及破解方法在文章底部)

    Adobe Creative Cloud 软件于2016.11.2 全面更新,Adobe Creative Cloud 2017 震撼登场 全新的 2017版本,包含 Photoshop.Illust ...

  4. CXF Spring开发WebService,基于SOAP和REST方式 【转】

    官网示例 http://cxf.apache.org/docs/writing-a-service-with-spring.html http://cxf.apache.org/docs/jax-rs ...

  5. openfire使用自定义用户表

    转自:http://blog.csdn.net/nomousewch/article/details/7546083 在最近的项目中使用openfire服务器实现消息推送功能,如果使用openfire ...

  6. http 状态码

    一些常见的状态码为: 200 - 服务器成功返回网页 404 - 请求的网页不存在 503 - 服务不可用 详细分解: 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码. 代码 说明 ...

  7. FIFO简记

    FIFO( First In First Out)简单说就是指先进先出的存储方式,在高速外设读取时经常使用. FIFO从读写的时钟可分为同步和异步两种,从信号来说都有读.写使能信号,读.写数据总线,满 ...

  8. redhat note

    1,iptables -I INPUT 5 -m state --state NEW -p tcp --dport 80 -j ACCEPT

  9. UWP学习开发笔记记录(开篇)

    零零散散开发微软移动2年多了,基本上从未记录或写过任何笔记.所以打算写一些自己的心得和技术的分享,大家一起来共同探讨.虽然现在UWP的工作几乎没有了,但是我感觉大家都是在观望,再看接下来微软的动作,所 ...

  10. GCC-4.6.3编译linux2.6.32.12内核出现“重复的成员‘page’”错误的解决方法

    使用gcc4.6.3编译linux2.6.32.12内核出现错误如下: In file included from drivers/net/igbvf/ethtool.c:36:0: drivers/ ...