社区
C#
帖子详情
求一个combobox 绑定函数及其调用的例子
bkkkkk
2009-08-14 11:30:26
求一个combobox 绑定函数及其调用的例子
...全文
109
8
打赏
收藏
求一个combobox 绑定函数及其调用的例子
求一个combobox 绑定函数及其调用的例子
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
qqiuzaihui
2009-08-14
打赏
举报
回复
[Quote=引用 3 楼 bkkkkk 的回复:]
有没有select from 数据库那种的
[/Quote]
private void InitialCustomer()
{
DataTable dtData = null;
try
{
using (SqlConnection thisConnection = new SqlConnection(
@"Data Source=.;Initial Catalog=Northwind;Integrated Security=True"))
{
using (SqlDataAdapter thisAdapter = new SqlDataAdapter(
@"SELECT CustomerID, CompanyName FROM Customers", thisConnection))
{
dtData = new DataTable("Customer");
thisAdapter.Fill(dtData);
thisConnection.Close();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
dtData = null;
}
combobox.DataSource = dtData;
combobox.DisplayMember = "CustomerID";
combobox.ValueMember = "CompanyName";
}
其实一楼已经给你做好了, 你只需将数据库中的指定表填入DataTable就行了.
dancingbit
2009-08-14
打赏
举报
回复
[Quote=引用 3 楼 bkkkkk 的回复:]
有没有select from 数据库那种的
[/Quote]
没有区别,无非就是这个DataTable是在程序中创建的,访问数据库需要使用SqlDataAdapter来Fill一个。
bkkkkk
2009-08-14
打赏
举报
回复
有没有select from 数据库那种的
lendylixt
2009-08-14
打赏
举报
回复
[Quote=引用 1 楼 lovvver 的回复:]
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Text");
DataRow dr;
for(int i = 0 ; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i+1;
dr[1] = string.Format("text-{0}",i+1);
dt.Rows.Add(dr);
}
combobox.DataSource = dt;
combobox.DisplayMember = "Text";
combobox.ValueMember = "Id";
[/Quote]
最后加上
combobox.databind();
lovvver
2009-08-14
打赏
举报
回复
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Text");
DataRow dr;
for(int i = 0 ; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i+1;
dr[1] = string.Format("text-{0}",i+1);
dt.Rows.Add(dr);
}
combobox.DataSource = dt;
combobox.DisplayMember = "Text";
combobox.ValueMember = "Id";
无锡阔微信息科技
2009-08-14
打赏
举报
回复
这个就跟GridView差不多的
dancingbit
2009-08-14
打赏
举报
回复
[Quote=引用 6 楼 c123728529 的回复:]
private void Init_Combox()
{
string str = "select KuNumber from tb_CheKu";
OleDbDataReader dr = connection.GetReader(str);
string tmp = "";
while (dr.Read())
{
tmp = dr[0].ToString();
comboBox1.Items.Add(tmp);
}
comboBox1.SelectedIndex = 0;
}
这个比较简单
[/Quote]
这个不是绑定,只是简单地使用数据库中的数据填充ComboBox。
高效匠人
2009-08-14
打赏
举报
回复
private void Init_Combox()
{
string str = "select KuNumber from tb_CheKu";
OleDbDataReader dr = connection.GetReader(str);
string tmp = "";
while (dr.Read())
{
tmp = dr[0].ToString();
comboBox1.Items.Add(tmp);
}
comboBox1.SelectedIndex = 0;
}
这个比较简单
ComboBox
ComboBox
_API_download.htm combo_demo.htm
Tkinter
Combobox
教程[项目源码]
本文介绍了如何使用Python的Tkinter库创建
Combobox
下拉菜单。内容涵盖了从基础窗体创建到下拉菜单的具体实现,包括如何设置默认值、
绑定
事件以及获取用户选择的值。示例代码展示了在Windows7和Python3.7环境下,如何创建
一个
简单的窗体应用,其中包含
一个
下拉菜单,菜单项为“河北”、“河南”、“山东”,并默认选中第三个选项。此外,还演示了如何通过两种方法获取用户选择的值,并对下拉菜单的选择事件进行了
绑定
,以便在用户选择时执行特定
函数
。
datagridview中
绑定
combox,代码实现
datagridview中
绑定
combox,有代码 通过代码实现,向DataGridView中
绑定
combox.
extjs editgrid
combobox
回显
extjs editgrid
combobox
回显extjs editgrid
combobox
回显extjs editgrid
combobox
回显extjs editgrid
combobox
回显
combobox
_picture.rar
在
combobox
生成过程中加载imagelist图片,不需要单独重绘即可实现
combobox
加载图片
C#
111,128
社区成员
642,541
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章