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

合集下载

C中的ComBox控件详解

C中的ComBox控件详解

C中的ComBox控件详解C中的ComBox控件详解收藏VC中ComboBox使用详解一、如何添加/删除Combo Box内容1,在Combo Box控件属性的Data标签里面添加,一行表示C ombo Box下拉列表中的一行。

换行用ctrl+回车。

2,在程序初始化时动态添加如://控件内容初始化CString strTemp;((CComboBox*)GetDlgItem(IDC_COMBO_CF))->ResetConte nt();//消除现有所有内容for(int i=1;i<=100;i++){strTemp.Format("%d",i);((CComboBox*)GetDlgItem(IDC_COMBO_CF))->AddString(st rTemp);}3,下拉的时候添加如:CString strTemp;int iCount=((CComboBox*)GetDlgItem(IDC_COMBO_CF))-> GetCount();//取得目前已经有的行数if(iCount<1)//防止重复多次添加{((CComboBox*)GetDlgItem(IDC_COMBO_CF))->ResetConte nt();for(int i=1;i<=100;i++){strTemp.Format("%d",i);((CComboBox*)GetDlgItem(IDC_COMBO_CF))->AddString(st rTemp);}}4,删除DeleteString( UINT nIndex )//删除指定行,5,插入InsertString( int nIndex, LPCTSTR lpszItem )//将行插入到指定位置6,查找FindString( int nStartAfter, LPCTSTR lpszItem )//可以在当前所有行中查找指定的字符传的位置,nStartAfter指明从那一行开始进行查找。

combox属性配置

combox属性配置

配置项1、transform : Mixed要转换为组合框的id,DOM节点或者已有的select元素。

2、lazyRender : Boolean值为true时阻止ComboBox渲染直到该对象被请求(被渲染到Ext.Editor 组件的时候应该使用这个参数,默认为false)。

3、autoCreate : String/Object一个指定的DomHelper配置对象,如果为真则为一个默认对象({tag: "input", type: "text", size: "20", autocomplete: "off"})。

4、store : Ext.data.Store/Array该组合框绑定的数据仓库(默认为undefined)。

如是的string值,不要用""引起来,否则就不是object数据,而是字符串,这是一个很巧妙的关键点:把服务器的字符串转化为js的object数据,是不是超级方便//下面就几种数据以代码举例说明1.一维数组:["江西","湖北"],值同时赋给ComboBox的value和text2.二维和多维数组:[["one","bbar","111"],["two","tbar","222"]],第一维和第二维分别赋值给value和text,其他维忽略3.store类型:包括GroupingStore, JsonStore, SimpleStore.//我们分三步走://第一步:提供数据:var data=[['湖北','hubei'],['江西','jiangxi'],['安徽','anhui']];//第二步:导入到store中:var store = new Ext.data.SimpleStore({fields: ['chinese', 'english'],data : data});//第三步:把store托付给comboBox的storevar combo = new boBox({store: store,displayField:'english',//store字段中你要显示的字段,多字段必选参数,默认当mode 为remote时displayField为undefine,当select列表时displayField为"text"mode: 'local',//因为data已经取数据到本地了,所以'local',默认为"remote",枚举完emptyText:'请选择一个省份...',applyTo: 'combo'});5、title : String如果提供了,则会创建一个包含此文本的元素并被添加到下拉列表的顶部(默认为undefined,表示没有头部元素)。

Silverlight的ComboBox的绑定和取值

Silverlight的ComboBox的绑定和取值

Silverlight的ComboBox的绑定和取值Silverlight的ComboBox与winform中的ComboBox存在类似的地⽅,但也有不同之处,本章包含以下内容:⼀、ComboBox 如何添加和绑定数据。

⼆、ComboBox 如何添加⾃定义Item。

三、ComboBox 如何取得所选项的值。

⾸先我们在页⾯添加4个ComboBox分别⽤不同的形式进⾏绑定。

代码<ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox" VerticalAlignment="Top" Width="165" SelectionChanged="comboBox_SelectionChanged" /><ComboBox Height="23" HorizontalAlignment="Left" Margin="12,65,0,0" Name="comboBox1" VerticalAlignment="Top" Width="161" /> <ComboBox Height="27" HorizontalAlignment="Left" Margin="12,123,0,0" Name="comboBox2" VerticalAlignment="Top" Width="163" /> <ComboBox Height="23" HorizontalAlignment="Left" Margin="12,180,0,0" Name="comboBox3" VerticalAlignment="Top" Width="165" SelectionChanged="comboBox3_SelectionChanged" />接下来,我们先介绍添加和绑定数据的⽅法。

VC++之ComboBox的用法总结

VC++之ComboBox的用法总结

VC++之ComboBox的用法总结分类:MFC2012-05-16 23:17 12202人阅读评论(0) 收藏举报vc++dropdownlist1. 对话框中添加 combox 控件2. 添加变量定义 CComboBox m_droplist;3. 添加内容:m_dropbox.SetCurSel(1);m_dropbox.AddString("所有数据类型");m_dropbox.AddString("空气温度");m_dropbox.AddString("空气湿度");m_dropbox.AddString("土壤湿度");m_dropbox.AddString("土壤湿度");m_dropbox.AddString("数据2");m_dropbox.AddString("数据3");CComboBox控件详解CComboBox控件又称作组合框控件,其有三种形态可供选择,1.简单组合框(Simple)2.下拉组合框(Drop-down)3.下拉列表式组合框(Drop-down list).CComboBox控件的常用设置属性说明:type属性:里面一共有三个选项.就是其三种形式, 我们常用的是后两种形态,其区别就是Dropdown的编辑区为可编辑控件,而droplist为静态控件.Data属性:当程序初始化的时候,下拉列表将显示其属性里面的内容,内容用分号分隔.其属性只支持后2中形式,Sort 属性:对添加到下拉列表框中的数据自动进行排序,如果你不想他改变你的显示序列,把他设置成False.控件是一个窗口.其基类是为CWnd.所以CComboBox也可以使用CWnd的一些函数,它自己的函数有30几种.我写了一个示范程序,演示了一些常用的函数,你可以参考其代码看到其功能.注:m_cbox 为CComboBox控件的关联变量,m_end为EDIT控件的关联变量1.GetCount() 函数:用以获得列表框中的选项数目. int GetCount() const;(此乃函数原型,我会列在每条的后面) 下面的例子是程序中各个按钮里面的代码int i;CString str;i=m_cbox.GetCount();str.Format ("%d",i);m_end="一共有"+str+"个数据";UpdateData(FALSE);2.GetCurSel() 函数:用以得到用户选中下拉列表框中数据的索引值.返回的值是重0开始的,如果没有选择任何选项将会返回-1 Int GetCurSel() constint i;CString str;i=m_cbox.GetCurSel ();str.Format ("%d",i+1);if (i==-1) m_end="你什么都没有选";else m_end="你选的是第"+str+"项";UpdateData(FALSE);3.SetCurSel函数:选取列表框中的一个选项,索引从0开始,-1为什么都不选.当你需要把列表框中已经选取的内容清空时就可以使用这个函数;if(m_i<3) m_cbox.SetCurSel (m_i++);//m_i为int型变量用以计数else {m_cbox.SetCurSel (-1);m_i=0;}4.SetEditSel函数:设置编辑区中蓝色选中字段的长度, BOOLSetEditSel( intnStartChar,int nEndChar ); nStartChar是起始的位置,当设置为-1时为不选择任何字段,nEndChar是结束位置.还有一个对应的函数GetEditSel是取得其位置,在此不详解.m_cbox.SetEditSel (3,5);//在编辑框中打入一串数字在按此按钮就能看到效果//其作用就是选中第3到第5个字符作为热点5.Clear() Cut() Paste() Copy() 这四个函数我放在一起说,因为他们都是针对编辑框中选定的文字进行编辑的函数,很多初学者很不明白这4个函数,使用这些函数没有作用,其实不然,这些函数对于在编辑框中的内容不进行处理,他真正处理的是你用鼠标选中的内容,对于Clear()函数很多书中解释都是有误的,很多书中对他的解释是清除当前选中的文本,我认为这样的解释是有歧异的,真正的解释是把你刚选中的文本释放掉,也就是不选,而不是把选中的删除,真正的删除选中的文本的函数是Cut(),Copy()是复制选中的文本,Paste()是粘贴到光标处.其演示就不写在程序中,有兴趣的朋友可以自己试试.6.LimitText()函数.其作用是限制在编辑框中键入的文本长度,BOOL LimitText(int nMaxChars); 当nMaxChars为0时,不是不能输入,而是长度最大化为65535字节7.GetLBText()函数.其原型为void GetLBText( int nIndex,CString&rString ).nIndex为列表框中数据的索引值,rString 为字符串,其作用就是把索引号为nIndex的数据放到rString变量中.与其对应的GetLBTextLen(intnIndex)函数就是得到索引号为nIndex中数据的长度m_cbox.GetLBText (2,m_end); // GetLBText按钮UpdateData(0);CString str; //GetLBTextLen按钮int i=m_cbox.GetLBTextLen (2);str.Format ("%d",i);m_end=str;UpdateData(FALSE);8.AddString() DeleteString() InsertString() ResetContent() 四个函数放在一起,他们都是针对下拉列表框的处理函数, AddString(LPCTSTR lpszString) 是在列表框的尾巴添加一条数据,参数为字符串. DeleteString(UINT nIndex)为删除指定索引为nIndex的数据. InsertString(int nIndex, LPCTSTR lpszString)在索引nIndex处插入IpszString的内容. ResetContent()是清除列表框中所有的内容.9.SetDroppedWidth(UINT nWidth) 函数.用于设定下拉列表框的最小宽度,当下拉列表框中的数据很长不能完全显示时,我们可以使用这个函数把列表框的宽度设置的大些.同样GetDroppedWidth()是返回列表框的宽度.以下为总结了各大论坛中对CCombBox控件使用的问题.并给出了正解.1.关于CComboBox在对话框中没有下拉项目的问题答: 资源编辑器中对话框中CComboBox组件的垂直范围拉大了下,就看见字体了,看到那个向下的黑箭头了吗,点他下拉,嘿嘿就这么简单.2.请问怎样能让CCombobox记住用户的输入.下次使用时还有答: 要记住用户的输入必须用到文件读写,或者把内容添加到注册表中,我会在以后给出解决办法.3. CCOMBOBOX如何使它只读,不能编辑答: 看了本文的介绍也许你现在知道了, CCOMBOBOX有三种类型的,选择你需要的吧!4. 我要让界面一显示,就能在Combo框中显示默认的数据答: 你要在OnInitDialog里面加上我上面所提到的SetCurSel()函数就行了.5. 如何把选好的内容赋给变量答: 先给CCOMBOBOX设置一个CString关联变量,再添加事件处理函数CBN_ Selchange.使用UpdateData(FALSE)就行了.6. 在CComboBox组合框中,条目的对齐方式是左对齐,能设置为对中或者右对齐吗?答: 没有直接的方法,你必须自己对齐, 比如最大长度是10int i;String.Format("%10d", i);CComboBox->AddStringVC combobox 使用大全---------------------------------------------------一、如何添加/删除Combo Box内容1. 在Combo Box控件属性的Data标签里面添加,一行表示Combo Box下拉列表中的一行。

MFC——ComBox用法大全

MFC——ComBox用法大全

MFC——ComBox用法大全Combo Box (组合框)控件很简单,可以节省空间。

从用户角度来看,这个控件是由一个文本输入控件和一个下拉菜单组成的。

用户可以从一个预先定义的列表里选择一个选项,同时也可以直接在文本框里面输入文本。

下面的例子简要说明如何利用 MFC CComboBox Class来操作字符串列表。

1、定义控件对应变量假定已经创建了一个Dialog,并且从控件工具箱将 Combo Box 控件拖放到上面。

打开 Class Wizard,添加控件对应变量,如:CComboBox m_cbExamble;在后面的代码中会不断使用这个变量。

2、向控件添加 Items1) 在Combo Box控件属性的Data标签里面添加,一行表示Combo Box下拉列表中的一行。

换行用ctrl+回车。

2) 利用函数 AddString() 向 Combo Box 控件添加 Items,如:m_cbExample.AddString(“StringData1”);m_cbExample.AddString(“StringData2”);m_cbExample.AddStrin g(“StringData3”);3) 也可以调用函数 InsertString() 将 Item 插入指定位置 nIndex,如:m_cbExample.InsertString( nIndex, “StringData” );3、从控件得到选定的Item假设在控件列表中已经选定某项,现在要得到被选定项的内容,首先要得到该项的位置,然后得到对应位置的内容。

这里会用到两个函数,如:int nIndex = m_cbExample.GetCurSel();CString strCBText;m_cbExample.GetLBText( nIndex, strCBText);这样,得到的内容就保存在 strCBText 中。

若要选取当前内容,可调用函数GetWindowText(strCBText)。

Combox(MFC)下拉框操作——代码部分

Combox(MFC)下拉框操作——代码部分

Combox(MFC)下拉框操作——代码部分/********************************************************* ** ComboBox下拉框实例** *********************************************************/#pragma once#include"afxwin.h"#include<string>using namespace std ;// CComboxDlg 对话框typedef struct tagComboxItem{char key[50] ;char val[100] ;}SComboxItem ;class CComboxDlg : public CDialog{DECLARE_DYNAMIC(CComboxDlg)public:CComboxDlg(CWnd* pParent = NULL); // 标准构造函数virtual ~CComboxDlg();// 对话框数据enum { IDD = IDD_DLG_COMBOXSAMPLE };protected:virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持DECLARE_MESSAGE_MAP()public:CComboBox m_combox;public:CEdit m_key;public:CEdit m_val;public:CButton m_btnAdd;public:CButton m_btnEdit;public:CButton m_btnDel;public:afx_msg void OnBnClickedBtnAdd();public:afx_msg void OnBnClickedBtnDel();public:afx_msg void OnBnClickedBtnEdit();public:afx_msg void OnCbnSelchangeCombo();};//////////////////////////////////////////// ComboxDlg.cpp : 实现文件//#include"stdafx.h"#include"MFC1.h"#include"ComboxDlg.h"// CComboxDlg 对话框IMPLEMENT_DYNAMIC(CComboxDlg, CDialog)CComboxDlg::CComboxDlg(CWnd* pParent/*=NULL*/): CDialog(CComboxDlg::IDD, pParent){}CComboxDlg::~CComboxDlg(){}void CComboxDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX, IDC_COMBO, m_combox);DDX_Control(pDX, IDC_EDIT_KEY, m_key);DDX_Control(pDX, IDC_EDIT_V AL, m_val);DDX_Control(pDX, IDC_BTN_ADD, m_btnAdd);DDX_Control(pDX, IDC_BTN_EDIT, m_btnEdit);DDX_Control(pDX, IDC_BTN_DEL, m_btnDel);}BEGIN_MESSAGE_MAP(CComboxDlg, CDialog)ON_BN_CLICKED(IDC_BTN_ADD, &CComboxDlg::OnBnClickedBtnAdd)ON_BN_CLICKED(IDC_BTN_DEL, &CComboxDlg::OnBnClickedBtnDel)ON_BN_CLICKED(IDC_BTN_EDIT, &CComboxDlg::OnBnClickedBtnEdit)ON_CBN_SELCHANGE(IDC_COMBO, &CComboxDlg::OnCbnSelchangeCombo) END_MESSAGE_MAP()// CComboxDlg 消息处理程序void CComboxDlg::OnBnClickedBtnAdd(){// TODO: 在此添加控件通知处理程序代码CString sKey("") ;CString sV al("") ;m_key.GetWindowText(sKey) ;m_val.GetWindowText(sV al) ;SComboxItem *item = (SComboxItem*)malloc(sizeof(SComboxItem)) ;strcpy(item->key,sKey.GetBuffer()) ;strcpy(item->val,sV al.GetBuffer()) ;int nIndex = m_combox.InsertString(-1,sV al) ;m_combox.SetItemDataPtr(nIndex,item) ;}void CComboxDlg::OnBnClickedBtnDel(){// TODO: 在此添加控件通知处理程序代码int nIndex = m_combox.GetCurSel() ;m_combox.DeleteString(nIndex) ;}void CComboxDlg::OnBnClickedBtnEdit(){}void CComboxDlg::OnCbnSelchangeCombo(){// TODO: 在此添加控件通知处理程序代码int nIndex = m_combox.GetCurSel() ;void *pData= m_combox.GetItemDataPtr(nIndex) ;SComboxItem *item = (SComboxItem*)pData ;m_key.SetWindowText(item->key) ;m_val.SetWindowText(item->val) ;}。

ComboBox有几个不同的属性用来获取当前选取的选项

ComboBox有几个不同的属性用来获取当前选取的选项

ComboBox有几个不同的属性用来获取当前选取的选项:ComboBox1.Text、ComboBox1.SelectedIndex、ComboBox1.SelectedItem、ComboBox1.SelectedText、ComboBox1.SelectedV alue 。

SelectedIndex获取的是选中项的索引,从0开始;SelectedItem获取的是选中项本身,这里返回的Object类型的一个对象,不一定是选中项的文本。

比如现在我们将ComboBox绑定到一个DataReader上,如果我们使用SelectedItem.ToString()的话,返回的是:System.Data.DataRowV iew,这表明返回的是一个System.Data.DataRowV iew的对象,然后转换为Object返回。

SelectedV alue获取或设置由V alueMember 属性指定的成员属性的值(MSDN)。

即是说要绑定了数据源之后才能使用这个属性。

SelectedText获取或设置ComboBox 的可编辑部分中选定的文本(MSDN)。

为了测试这个属性,我们使用一个click进行测试,返回的是一个空字符串,关于这个原因,MSDN 的解释是:當下拉式方塊失去焦點時,選取範圍點就會移至文字的開頭,而任何原本選取的文字就會變成未選取狀態。

在這個範例中,取得SelectedText 屬性就會擷取空字串,而設定SelectedText 屬性就會將指定的值加入至文字的開頭。

(/zh-cn/library/bobox.selectedtext(zh-tw). aspx)。

再用SelectedIndexChanged事件进行测试,结果还是空字符串,原因是:當使用者選取下拉式清單中的項目,或使用向上鍵和向下鍵,就會自動選取新項目的文字。

但是,當您嘗試取得SelectedIndexChanged 或SelectedV alueChanged 事件處理常式中的SelectedText 值時,這個屬性會傳回一個空字串。

vc++中组合框ComboBox的使用

vc++中组合框ComboBox的使用
四、取得Combo Box框内内容
1取当前内容
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetWindowText(strTemp);
2取其他行内容
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetLBText(n,strTemp);
ON_CBN_SELCHANGE列表框中选择的行发生改变
ON_CBN_EDITUPDATE输入框中内容被更新
For(int i=1;i<=100;i++)
{
strTemp.Format(“%d”,i);
((CComboBox*)GetDlgItem(IDC_COMBO_CF))->AddString(strTemp);
}
3下拉的时候添加,如:
CString strTemp;
int iCount=((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetCount();//取得目前已有行数
if((GetFocus()->GetParent())==GetDlgItem(IDC_COMBO_CF))
六、Combo Box的消息映射宏
ON_CBN_DBLCLK鼠标双击
ON_CBN_DROPDOWN列表框被弹出
ON_CBN_KILLFOCUS/ON_CBN_SETFOCUS在输入框失去/得到输入焦点时产生
三、选择其中的某行
1选中
intiPos=((CComboBox*)GetDlgItem(IDC_COMBO_CF))->GetCurSel();//当前选中的行
2设置((CComboBo*)GetDlgItem(IDC_COMBO_CF))->SetCurSel(n);//设置第n行内容为显示内容

C#WinForm_ComboBox数据绑定的问题

C#WinForm_ComboBox数据绑定的问题

C#WinForm_ComboBox数据绑定的问题Visual Studio C#中的数据绑定五.复杂型组件的数据绑定:在上面的介绍中,了解到对复杂型组件的数据绑定是通过设定组件的某些属性来完成数据绑定的。

首先来介绍一下ComboBox组件的数据绑定.(1).ComboBox组件的数据绑定:在得到数据集后,只有设定好ComboBox组件的的三个属性就可以完成数据绑定了,这三个属性是:、"DisplayMember"、"ValueMember"。

其中"DataSource"是要显示的数据集,"DisplayMember"是ComboBox 组件显示的字段,"ValueMember"是实际使用值。

具体如下:ComboBox1.DataSource = myDataSet ;ComboBox1.DisplayMember = "person.xm" ;ComboBox1.ValueMember = "person.xm" ;注释:此时绑定是Access 2000数据库中"person"表的"xm"字段。

由此可以得到ComboBox组件数据绑定的源程序代码(Combo01.cs),本代码操作数据库是Access 2000:public class Form1 : Form{private ComboBox ComboBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private/doc/5612742ced630b1c59eeb5fe.html ponentModel.Container components = null ;public Form1 ( ){file://打开数据链接,得到数据集GetConnect ( ) ;InitializeComponent ( ) ;}file://清除程序中使用过的资源protected override void Dispose ( bool disposing ){if ( disposing ){if ( components != null ){components.Dispose ( ) ;}}base.Dispose ( disposing ) ;}private void GetConnect ( ){file://创建一个OleDbConnectionstring strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = db.mdb" ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;string strCom = " SELECT * FROM person " ;file://创建一个DataSetmyDataSet = new DataSet ( ) ;myConn.Open ( ) ;file://用OleDbDataAdapter 得到一个数据集OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;file://把Dataset绑定person数据表myCommand.Fill ( myDataSet , "person" ) ;file://关闭此OleDbConnectionmyConn.Close ( ) ;}private void button1_Click ( object sender , System.EventArgs e ){ComboBox1.DataSource = myDataSet ;ComboBox1.DisplayMember = "person.xm" ;ComboBox1.ValueMember = "person.xm" ;}static void Main ( ){Application.Run ( new Form1 ( ) ) ;}}图03:对ComboBox组件数据绑定的程序界面得到了ComboBox组件对本地数据库的数据绑定程序,也就十分方便的得到ComboBox组件绑定Sql Server 2000源程序代码(Combox02.cs)具体如下:public class Form1 : Form{private ComboBox ComboBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private/doc/5612742ced630b1c59eeb5fe.html ponentModel.Container components = null ;public Form1 ( ){file://打开数据链接,得到数据集GetConnect ( ) ;InitializeComponent ( ) ;}file://清除程序中使用过的资源protected override void Dispose ( bool disposing ){if ( disposing ){if ( components != null ){components.Dispose ( ) ;}}base.Dispose ( disposing ) ;}private void GetConnect ( ){// 设定数据连接字符串,此字符串的意思是打开Sql server数据库,服务器名称为server1,数据库为data1 string strCon = "Provider = SQLOLEDB.1 ; Persist Security Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1 " ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;myConn.Open ( ) ;string strCom = " SELECT * FROM person " ;file://创建一个DataSetmyDataSet = new DataSet ( ) ;file://用OleDbDataAdapter 得到一个数据集OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;file://把Dataset绑定person数据表myCommand.Fill ( myDataSet , " person " ) ;file://关闭此OleDbConnectionmyConn.Close ( ) ;}private void button1_Click ( object sender , System.EventArgs e ){ComboBox1.DataSource = myDataSet ;ComboBox1.DisplayMember = "person.xm" ;ComboBox1.ValueMember = "person.xm" ;}static void Main ( ){Application.Run ( new Form1 ( ) ) ;}}C# WinForm 中ComboBox数据绑定的问题2009-12-29 09:24怎样让WinForm中的ComboBox显示表中的一个字段,同时又绑定另一个字段?在Web中的ComboBox这样写可以绑定两个值:/doc/5612742ced630b1c59eeb5fe.ht ml boBox1.DataTextField="B000602";//显示中文,方便用户选择/doc/5612742ced630b1c59eeb5fe.ht ml boBox1.DataValueField="B000601";//绑定与选择对应的另一个值/doc/5612742ced630b1c59eeb5fe.html boBox1.DataBind();但是在WinForm程序中该怎么写啊?0******************************************************************DataSet ds = new DataSet();//这个DataSet是你从数据库里取出来的值string[] arr = new string[ds.Tables[0].Rows.Count];for (int i = 0; i < arr.Length; i++){arr[i] = ds.Tables[0].Rows[i][2].ToString();}textBox1.AutoCompleteCustomSource.AddRange(arr);textBox1.AutoCompleteSource =AutoCompleteSource.CustomSource;textBox1.AutoCompleteMode =AutoCompleteMode.SuggestAppend;1.************************************************************* ****** 假设combobox绑定的列表为DataSet2的ListTable表(含有ListID, ListName字段),需要绑定的记录字段为DataSet1的T able1表的ListID字段combobox.DataSource = dataset2.Tables["ListTable"]; combobox.DisplayMember = "ListName";combobox.ValueMember = "ListID";combobox.DataBindings.Add("SelectedValue", dataset1, "Table1.List ID");2.************************************************************* **** //dt为数据表,ID,Name为dt的两个字段:comboBox1.DataSource = dt ;comboBox1.ValueMember ="ID";comboBox1.DisplayMember ="Name";3.************************************************************* *****SqlConnection con = new SqlConnection("server=192.168.2.198;uid=sa;pwd=sa;database=northwin d"); SqlCommand cmd = con.CreateCommand();/doc/5612742ced630b1c59eeb5fe.ht ml mandT ext = "Select * from Customers where countr y='USA'";SqlDataAdapter adp = new SqlDataAdapter();adp.SelectCommand = cmd;DataSet ds = new DataSet();adp.Fill(ds, "Customers");comboBox1.DataSource = ds.Tables["Customers"];comboBox1.DisplayMember = "CompanyName";comboBox1.ValueMember = "CompanyName";++++++++++++++++或者++++++++++++++++++++++SqlConnection con = new SqlConnection("server=192.168.2.198;uid=sa;pwd=sa;database=northwin d"); SqlCommand cmd = con.CreateCommand();/doc/5612742ced630b1c59eeb5fe.ht ml mandT ext = "Select * from Customers where countr y='USA'";SqlDataAdapter adp = new SqlDataAdapter();adp.SelectCommand = cmd;DataSet ds = new DataSet();adp.Fill(ds, "Customers");comboBox1.DataSource = ds;comboBox1.DisplayMember = "/doc/5612742ced630b1c59eeb5fe.html panyName";comboBox1.ValueMember = "/doc/5612742ced630b1c59eeb5fe.html panyName";++++++++++++往DataGrid里添加下拉列表++++++++++++ DataGridTableStyle dgt = new DataGridTableStyle();dgt.MappingName = "test";DataGridTextBoxColumn dgtbc = new DataGridTextBoxColumn(); dgtbc.MappingName = "name";dgtbc.HeaderText= "name";ComboBox cmbFunctionArea = new ComboBox(); cmbFunctionArea.DataSource = DtGeneral;cmbFunctionArea.DisplayMember = "name"; cmbFunctionArea.ValueMember = "value";cmbFunctionArea.Cursor = Cursors.Arrow;cmbFunctionArea.DropDownStyle=ComboBoxStyle.DropDownList;cmbFunctionArea.Dock = DockStyle.Fill;dgtbc.TextBox.Controls.Add(cmbFunctionArea);dgt.GridColumnStyles.Add(dgtbc);cmbFunctionArea.SelectionChangeCommitted +=new EventHandler(cmbFunctionArea_SelectionChangeCommitted);+++++++++++++修改++++++++++++++++private void cmbFunctionArea_SelectionChangeCommitted(object se nder, EventArgs e){((DataTable)dataGrid1.DataSource).Rows[dataGrid1.Current RowIndex][0] = ((ComboBox)sender).T ext.ToString();dataGrid1.SetDataBinding(DtGeneral,null);}4.******************************************************************* *****DataBindings是一般控件所具有的,是绑定数据源的某一个字段combobox.DataBindings.Add("要绑定控件的属性如下拉框的SelectedValue\Text", 数据源如dataset1, "导航路径如Table1.ListID");但是,DataBindings只能绑定一个字段,而绑定多个字段时典型的如列表控件Combobox、ListBox控件,需要键值对,这时就需要指定DataSource(实现IList接口就行),然后指定ValueMember、DisplayMember 。

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

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

combox取值的用法c#-个人经验comboxIlist 如果绑定的是List那需要绑定实体类里的属性名comboBox1.DisplayMember User_NamecomboBox1.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.DataSourcedbProductCate.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_pricea.product_stockb.cate_name sql from product_list aproduct_cateb where a.cate_idb.cate_iddgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignment DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSourcedbProductList.getAllProductBySqlsql private void combParentCate_SelectedValueChangedobject sender EventArgs e //combParentCate1.GetItemTextcate_id.ToString //int tmpCateIdConvert.T oInt32combParentCate1.SelectedValue.T oString string sql select a.product_ida.cate_id a.product_name sqla.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 tmpCateIddgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignme nt DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSourcedbProductList.getAllProductBySqlsql private voidbtnSearch_Clickobject sender EventArgs e int tmpCateId Convert.T oInt32combParentCate.SelectedValue.T oString string sql select a.product_ida.cate_id a.product_name sql a.item_pricea.product_stockb.cate_name sql from product_list aproduct_cateb where a.cate_idb.cate_id if tmpCateId0 sql and a.cate_id tmpCateIddgvSelectStockList.ColumnHeadersDefaultCellStyle.Alignme nt DataGridViewContentAlignment.MiddleCenter dgvSelectStockList.DataSourcedbProductList.getAllProductBySqlsql datasetcombox 如:DataSet userDs dbSysAdminUser.getAllUserDataset combUser.DataSource userDs.Tablessys_adminuser combUser.DisplayMember user_name combUser.ValueMemberuser_id /// 用户名更换的时候提示权限private void combUser_SelectedValueChangedobject sender EventArgs e DataRowView tmpdrv DataRowViewcombUser.SelectedItem int tmpUserId Convert.ToInt32tmpdrv.Rowuser_id.ToString permissions_group tmpGroupIddbSysAdminUser.getSysUserByIdConvert.ToInt32tmpUserId.G roup_id lbPermission.Text tmpGroupId.Group_name。

WPFCombox实现下拉多选,可选中多个值

WPFCombox实现下拉多选,可选中多个值

WPFCombox实现下拉多选,可选中多个值⾃定义多选MultiCombox,可以实现下拉列表多选using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;namespace MES.Plugin.Report.Controls{public class MultiComboBox : ComboBox{static MultiComboBox(){DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiComboBox), new FrameworkPropertyMetadata(typeof(MultiComboBox)));}private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){d.SetValue(e.Property, e.NewValue);}/// <summary>/// 选中项列表/// </summary>public ObservableCollection<MultiCbxBaseData> ChekedItems = new ObservableCollection<MultiCbxBaseData>();/// <summary>/// ListBox竖向列表/// </summary>private ListBox _ListBoxV;/// <summary>/// ListBox横向列表/// </summary>private ListBox _ListBoxH;public override void OnApplyTemplate(){base.OnApplyTemplate();_ListBoxV = Template.FindName("PART_ListBox", this) as ListBox;_ListBoxH = Template.FindName("PART_ListBoxChk", this) as ListBox;_ListBoxH.ItemsSource = ChekedItems;_ListBoxV.SelectionChanged += _ListBoxV_SelectionChanged;_ListBoxH.SelectionChanged += _ListBoxH_SelectionChanged;if (ItemsSource != null){foreach (var item in ItemsSource){MultiCbxBaseData bdc = item as MultiCbxBaseData;if (bdc.IsCheck){_ListBoxV.SelectedItems.Add(bdc);}}}}private void _ListBoxH_SelectionChanged(object sender, SelectionChangedEventArgs e){foreach (var item in e.RemovedItems){MultiCbxBaseData datachk = item as MultiCbxBaseData;for (int i = 0; i < _ListBoxV.SelectedItems.Count; i++){MultiCbxBaseData datachklist = _ListBoxV.SelectedItems[i] as MultiCbxBaseData;if (datachklist.ID == datachk.ID){_ListBoxV.SelectedItems.Remove(_ListBoxV.SelectedItems[i]);}}}}void _ListBoxV_SelectionChanged(object sender, SelectionChangedEventArgs e){foreach (var item in e.AddedItems){MultiCbxBaseData datachk = item as MultiCbxBaseData;datachk.IsCheck = true;if (ChekedItems.IndexOf(datachk) < 0){ChekedItems.Add(datachk);}}foreach (var item in e.RemovedItems){MultiCbxBaseData datachk = item as MultiCbxBaseData;datachk.IsCheck = false;ChekedItems.Remove(datachk);}}public class MultiCbxBaseData{private int _id;public int ID{get { return _id; }set { _id = value; }}private string _viewName;public string ViewName{get { return _viewName; }set{_viewName = value;}}private bool _isCheck;/// <summary>/// 是否选中/// </summary>public bool IsCheck{get { return _isCheck; }set { _isCheck = value; }}}}}Style: ComboBox.xmal<ResourceDictionary xmlns="/winfx/2006/xaml/presentation"xmlns:x="/winfx/2006/xaml"xmlns:local="clr-namespace:MES.Plugin.Report"xmlns:controls="clr-namespace:MES.Plugin.Report.Controls"><!--ComboBox--><!--ComBoBox项选中背景⾊--><SolidColorBrush x:Key="ComboBoxSelectdBackground" Color="#ff8c69"/><!--ComBoBox项⿏标经过背景⾊--><SolidColorBrush x:Key="ComboBoxMouseOverBackground" Color="#ff3030"/><!--ComBoBox项选中前景⾊--><SolidColorBrush x:Key="ComboBoxSelectedForeground" Color="White"/><!--ComBoBox项⿏标经过前景⾊--><SolidColorBrush x:Key="ComboBoxMouseOverForegrond" Color="White"/><ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"><Grid Height="25" HorizontalAlignment="Stretch"><Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="30"/></Grid.ColumnDefinitions><Border Background="White" Grid.ColumnSpan="2" Opacity="0"/><Path x:Name="Arrow" Grid.Column="1" Data="M 0 0 6 6 12 0 Z" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" Fill="#999" /></Grid><ControlTemplate.Triggers><Trigger Property="IsChecked" Value="true"><Setter TargetName="Arrow" Property="RenderTransform"><Setter.Value><RotateTransform CenterX="6" CenterY="3" Angle="180"></RotateTransform></Setter.Value></Setter><Setter TargetName="Arrow" Property="Margin" Value="0 0 0 2"/></Trigger></ControlTemplate.Triggers></ControlTemplate><!--MultiComboBox普通样式--><Style TargetType="{x:Type controls:MultiComboBox}"><Setter Property="Width" Value="200" /><Setter Property="HorizontalContentAlignment" Value="Stretch" /><Setter Property="VerticalContentAlignment" Value="Center" /><Setter Property="SnapsToDevicePixels" Value="True" /><Setter Property="MaxDropDownHeight" Value="400" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type controls:MultiComboBox}"><Grid><Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderBrush="#eaeaea" BorderThickness="1" ><Grid x:Name="PART_Root"><Grid x:Name="PART_InnerGrid" Margin="0"><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="0.3*" MaxWidth="30" /></Grid.ColumnDefinitions><ListBox x:Name="PART_ListBoxChk" Background="#2d2f3e" SelectionMode="Multiple" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Disabled"><ListBox.ItemsPanel><ItemsPanelTemplate><VirtualizingStackPanel Orientation="Horizontal" VirtualizingStackPanel.IsVirtualizing="True" /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemContainerStyle><Style TargetType="ListBoxItem"><Setter Property="BorderThickness" Value="0"/><Setter Property="IsSelected" Value="True"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ListBoxItem"><CheckBox BorderThickness="0" Background="#2d2f3e" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{Binding ViewName}" IsChecked="{Binding Path=IsSele </ControlTemplate></Setter.Value></Setter></Style></ListBox.ItemContainerStyle></ListBox><!--下拉按钮--><ToggleButton x:Name="PART_DropDownToggle" IsTabStop="False"IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"Grid.Column="1" Template="{StaticResource ComboBoxToggleButton}" /></Grid></Grid></Border><!--弹出多选列表--><Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" StaysOpen="False"IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"PopupAnimation="{DynamicResource {x:Static boBoxPopupAnimationKey}}" Placement="Bottom"><Grid Width="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" MaxHeight="{Binding MaxDropDownHeight, RelativeSource={RelativeSource TemplatedParent}}" ><ListBox x:Name="PART_ListBox" SelectionMode="Multiple" BorderThickness="1 0 1 1" Background="White" ItemsSource="{Binding ItemsSource,RelativeSource={RelativeSource TemplatedParent}}"MaxHeight="{TemplateBinding MaxDropDownHeight}" BorderBrush="#eaeaea" ><ListBox.ItemContainerStyle><Style TargetType="ListBoxItem"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}" ><Grid Height="22"><Border x:Name="bg" BorderBrush="#eaeaea" BorderThickness="0"/><ContentPresenter x:Name="content" /><Border Background="White" Opacity="0"/></Grid><ControlTemplate.Triggers><Trigger Property="IsSelected" Value="True"><Setter TargetName="bg" Property="Background" Value="#ADD6FF" /></Trigger><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsMouseOver" Value="true" /><Condition Property="IsSelected" Value="false"/></MultiTrigger.Conditions><Setter TargetName="bg" Property="Background" Value="#009BDB" /><Setter TargetName="bg" Property="Opacity" Value="0.7"/><Setter Property="Foreground" Value="White" /></MultiTrigger><Trigger Property="IsEnabled" Value="False"><Setter TargetName="bg" Property="Opacity" Value="0.3" /><Setter Property="Foreground" Value="Gray" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ListBox.ItemContainerStyle><ListBox.ItemTemplate><DataTemplate><Grid><CheckBox x:Name="chk" Visibility="Hidden" IsChecked="{Binding IsCheck,Mode=TwoWay}" VerticalAlignment="Center"/><CheckBox VerticalAlignment="Center" Foreground="{Binding Foreground,RelativeSource={RelativeSource AncestorType=ListBoxItem}}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=L </Grid><DataTemplate.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="true"><Setter TargetName="chk" Property="IsChecked" Value="true"/></DataTrigger><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="false"><Setter TargetName="chk" Property="IsChecked" Value="false"/></DataTrigger></DataTemplate.Triggers></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Popup></Grid></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>前端使⽤:1.引⽤Style资源,在前端引⽤上⾯建好的ComboBox.xmal 样式2.控件使⽤<controls:MultiComboBox x:Name="MultiCmb" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="6" Grid.Row="0"Width="Auto"/>3.MutilComboBox 数据源绑定,刷新数据源ObservableCollection<Controls.MultiComboBox.MultiCbxBaseData> MultiComboBoxListData = new ObservableCollection<Controls.MultiComboBox.MultiCbxBaseData>();for (int i = 0; i<LstLine.Count; i++){SFC_WORKCENTER workcenter = LstLine[i];if (string.IsNullOrEmpty(workcenter.ID)) continue;if (workcenter.WORKCENTER_NAME.Contains("过塑")) {MultiComboBoxListData.Add(new Controls.MultiComboBox.MultiCbxBaseData(){ID = i,ViewName = workcenter.WORKCENTER_CODE,//LineName = workcenter.WORKCENTER_NAME,IsCheck = false});}else{MultiComboBoxListData.Add(new Controls.MultiComboBox.MultiCbxBaseData(){ID = i,ViewName = workcenter.WORKCENTER_CODE,//LineName = workcenter.WORKCENTER_NAME,IsCheck = true});}}plugin.MultiCmb.ItemsSource = MultiComboBoxListData; plugin.MultiCmb.OnApplyTemplate();。

C#中Combox的绑定总结

C#中Combox的绑定总结

C#中Combox的绑定总结刚来实习,经理让修改一个考试系统,看到以前的老前辈的代码,感觉和自己以前在学校接触的不一样,特此总结一下Combox的绑定,虽然这个问题都是老生常谈的东西了。

感觉自己总结过了,明白了,反思了才会懂得,理解,以后也会运用自如了。

1,下面是前辈的例子,首先从数据库中得到ds数据集然后进行循环绑定添加items项foreach(DataRow dr in ds.Tables[0].Rows){b_type.Items.Add(newControlItem(dr,dr["answertypename"].ToString()));}b_type.SelectedIndex =0;2,自己在学校学习的是绑定dt数据表或ds数据集。

这样就不用循环添加items项了,感觉代码简练了很多。

b_type.DataSource = dt;//也可以用ds,此处就是ds.Tables[0];b_type.DisplayMember = "answertypename"; //绑定显示成员的名字_answertype.ValueMember = "answertypeID";//绑定combox显示成员的值_answertype.SelectedValue = "0";//让combox固定显示某个成员名字。

3,可以设置combox的DisplayMember,ValueMemeberValueMemeber 是combox的值成员,而DisplayMember是combox的显示成员。

控件属性设置和代码中设置功能是一样的。

4,绑定datasourse后,怎么样让combox添加一项“请选择”在asp中直接一句话:this.DropDownList1.Items.Insert(0,new ListItem( "请选择", "0 "));但在winform中,绑定datasourse后就不能简单实现添加“请选择”项了。

C#WinformComboBox在输入内容时会在下拉菜单中显示根据输入内容查询的结果

C#WinformComboBox在输入内容时会在下拉菜单中显示根据输入内容查询的结果

C#WinformComboBox在输入内容时会在下拉菜单中显示根据输入内容查询的结果将ComboBox的AutoCompleteMode属性置为SuggestAppend,AutoCompleteSource属性置为ListItems,然后给ComboBox随便塞几个子项,运行看效果。

扩展: AutoCompleteMode允许有四种值: None:默认值,指示ComboBox 不使用自动功能。

Suggest:在ComboBox中输入字符后,ComboBox会自动展开,显示匹配的子项,输入行不受影响,需要自己输入后续字符,或者在下拉框中点选完整子项。

Append:输入字符后,字符后会自动补充匹配内容(以反色显示),但是ComboBox不会展开。

按上下键可以在多个匹配内容中切换。

SuggestAppend:上述两种模式的组合。

AutoCompleteSource属性,共有9种,指示自动完成将要在其中进行查找的数据源。

常用的几种如下: ListItems:数据源为ComboBox的Item集合。

FileSystem:文件系统。

例如输入c:\后会展开c:\下的目录列表(或append模式下的自动添加)。

同样的,此数据源也支持文件名的补全。

CustomSource:自定义数据源。

选用此方式时必须在代码中指定ComboBox的AutoCompleteCustomSource属性为你构建的AutoCompleteStringCollection对象,否则不会生效。

AutoCompleteStringCollection类似于List<string>,将你的数据add进去即可。

[高质量编程]团队成员为您解答,请提出宝贵意见和建议。

谢谢! QQ:176229432 补充回答: 首先我需要强调一点,使用拼音首字母检索时可能比较适合DropDownStyle=DropDownList时。

以下是我项目中一个控件库中的扩展组件完整代码,编译成组件丢到其他UI中,所有ComboBox和ListBox均会添加扩展属性SearchOnKeyEnable,置为true后自己看效果。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18: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_stock
b.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_stock
b.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_stock
b.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.G roup_id lbPermission.Text tmpGroupId.Group_name。

相关文档
最新文档