zoukankan      html  css  js  c++  java
  • 对COMBOX控件的SelectedValue为空的问题

    //实践表明,不初始化combox控件的数据源,则无法对SelectedValue进行赋值
                        //因为赋值后赋值等式右边虽然有值,但SelectedValue确仍为空,具体什么原因不明?
                        initializeDatasource();
                        
                        dtp_makeDate.Text = item.WeighingDate.ToString();
                        txt_weighingTime.Text = item.WeightingTime;
    
                        cmb_custName.SelectedValue =item.CusCode.ToString();
                        cmb_custName.Text = item.CusName;

    看有个网站,有如下解释:

    The SelectedValue property is used when you have linked the ComboBox to a data source, and want to return a value other than what is displayed.

    For example, say you have a table called "City" which is made up of two fields, "ZipCode" and "CityName."  You want to display to your application users the "CityName" value, but you are interested in storing the "ZipCode" value for the selected item.

    With your ComboBox control, you set the following properties:

    ComboBox.DataSource=City

    ComboBox.DisplayMember=CityName

    ComboBox.ValueMember=ZipCode

    The ComboBox.SelectedItem will be CityName, but ComboBox.SelectedValue will be ZipCode.

  • 相关阅读:
    css3
    ubuntu /mac 终端命令大全
    MarkDown的语法的简要规则
    向github上传一个项目
    datatable 去掉默认功能
    datatable 自定义筛选
    vuex
    es6入门教程
    datatable 指定添加排序,根据列的值来设置颜色
    在ios上块点击出现闪黑底
  • 原文地址:https://www.cnblogs.com/windy3417/p/13883346.html
Copyright © 2011-2022 走看看