combox取值的用法c#-个人经验

2019-01-19 16:30

comboxIlist 如果绑定的是List那需要绑定实体类里的属性名 comboBox1.DisplayMember User_Name comboBox1.ValueMember User_Ide 注意手动赋值comboBox1.SelectedIndex -1的时候也会触发

comboBox1_SelectedIndexChanged事件 需要得到被选中的文本时用的是comboBox1.Text不是comboBox1.SelectedText //SelectedText是指被鼠标框中的文本不是选中项的文本 //SelectedItem是指选中项所指向的对象 如果 //IList a collection.GetUser //comboBox1.DataSource a //那么

SelectedItem就代表IList里的其中一项 //如果toString的话就会出现 “namespace.class”(这是一个名称的字符串) 所以如果要获取combox中的value和值当当使用SelectedValueChanged方法时应该采用如下方法: product_catecombParentCate.SelectedItem.Cate_id 强转的类型改成你对应的实体类 如果在点击某个按钮事件的时候触发, 需要采用如下方法

combParentCate.SelectedValue.ToString private void frmSelectProduct_Loadobject sender EventArgs e combParentCate.DataSource

dbProductCate.getAllCateDatasetForCombox combParentCate.DisplayMember cate_name combParentCate.ValueMember cate_id

//combParentCate1.SelectedIndex -1 //初始化产品列表 string sql select a.product_ida.cate_id a.product_name sql a.item_price a.product_stockb.cate_name sql from product_list aproduct_cate b where a.cate_idb.cate_id

dgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignment DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSource

dbProductList.getAllProductBySqlsql private void combParentCate_SelectedValueChangedobject sender EventArgs e //combParentCate1.GetItemTextcate_id.ToString //int tmpCateId

Convert.ToInt32combParentCate1.SelectedValue.ToString string sql select a.product_ida.cate_id a.product_name sql a.item_price a.product_stockb.cate_name sql from product_list aproduct_cate b where a.cate_idb.cate_id if tmpCateId 0 sql and a.cate_id tmpCateId

dgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignment DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSource

dbProductList.getAllProductBySqlsql private void btnSearch_Clickobject sender EventArgs e int tmpCateId Convert.ToInt32combParentCate.SelectedValue.ToString string

sql select a.product_ida.cate_id a.product_name sql a.item_price a.product_stockb.cate_name sql from product_list aproduct_cate b where a.cate_idb.cate_id if tmpCateId0 sql and a.cate_id tmpCateId

dgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignment DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSource

dbProductList.getAllProductBySqlsql datasetcombox 如: DataSet userDs dbSysAdminUser.getAllUserDataset combUser.DataSource userDs.Tablessys_adminuser

combUser.DisplayMember user_name combUser.ValueMember user_id /// 用户名更换的时候提示权限 private void combUser_SelectedValueChangedobject sender EventArgs e DataRowView tmpdrv DataRowViewcombUser.SelectedItem int tmpUserId Convert.ToInt32tmpdrv.Rowuser_id.ToString permissions_group tmpGroupId

dbSysAdminUser.getSysUserByIdConvert.ToInt32tmpUserId.Group_id lbPermission.Text tmpGroupId.Group_name


combox取值的用法c#-个人经验.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:[英语]河南省洛阳市2010届高三上学期第一次统一考试

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: