社区
C#
帖子详情
c# 中comboBox所选择的值改变后为何不执行comboBox1_SelectedIndexChanged事件?
sdfger
2010-04-26 04:54:42
我的窗体中有一个comboBox1控件,我想让每当在下拉列表中选择另一个值时,执行下列代码
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("请选择要修改的用户名!");
}
但程序并没有转入执行,这是问什么啊?该怎么改?
我用的c#语言
...全文
785
6
打赏
收藏
c# 中comboBox所选择的值改变后为何不执行comboBox1_SelectedIndexChanged事件?
我的窗体中有一个comboBox1控件,我想让每当在下拉列表中选择另一个值时,执行下列代码 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { MessageBox.Show("请选择要修改的用户名!"); } 但程序并没有转入执行,这是问什么啊?该怎么改? 我用的c#语言
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
皇城龙三
2010-04-26
打赏
举报
回复
还有就是看看,你是否不小心把事件删除了
如果删除了,要选择上
捷哥1999
2010-04-26
打赏
举报
回复
在窗体中选择comboBox1,按下F4快捷键,定位到属性窗口上,选择事件,然后将SelectedIndexChanged关联到void comboBox1_SelectedIndexChanged
sdfger
2010-04-26
打赏
举报
回复
谢了,
皇城龙三
2010-04-26
打赏
举报
回复
从你贴出来的程序来看,没有任何问题
关键是看你comboBox的值是怎么设的?
你试试弄3行,3个值 ,1,2,3
选择一下
cyhf00808
2010-04-26
打赏
举报
回复
[Quote=引用 1 楼 showlin 的回复:]
设计器界面
选中combox1控件
查看属性面板
选中闪电样子的事件面板
检查
SelectedIndexChanged事件是否监听了comboBox1_SelectedIndexChanged代码
[/Quote]
同意
showlin
2010-04-26
打赏
举报
回复
设计器界面
选中combox1控件
查看属性面板
选中闪电样子的事件面板
检查
SelectedIndexChanged事件是否监听了comboBox1_SelectedIndexChanged代码
DevExpress
中
的repositoryItem
ComboBox
控件得到索引
值
和选项
值
DevExpress
中
的repositoryItem
ComboBox
控件得到索引
值
和选项
值
c#
读取odbc数据库,注释详细
包括Odbc数据库dsn的获取,表名的获取.界面代码概览:public Form1() { InitializeComponent(); List
dsnNames = DataSource.GetAllDSN(); //读取DSN for (int i = 0; i < dsnNames.Count; i++) { this.
comboBox
1.Items.Add(dsnNames[i]); } } private void
comboBox
1_
Selected
Index
Change
d(object sender, EventArgs e) { if (this.
comboBox
1.
Selected
Index
== -1) { return; } List
sheetNames = new List
(); try { DataSource.ConnectToDataBase(this.
comboBox
1.
Selected
Item.ToString(), this.txtUserName.Text, this.txtPassword.Text); sheetNames = DataSource.GetTableAndViewNamesFromDataBase(); } catch (Exception err) { MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < sheetNames.Count; i++) { this.
comboBox
2.Items.Add(sheetNames[i]); } } private void
comboBox
2_
Selected
Index
Change
d(object sender, EventArgs e) { DataTable dt; DataSource.GetTableFromDataBase(this.
comboBox
2.
Selected
Item.ToString(),out dt); this.dataGridView1.DataSource = dt; }
C#
程序设计 宾馆管理系统
本系统开发的是一个比较完善宾馆管理系统,是为了对宾馆的住房和人员有一个较好的管理,为此开发了“宾馆管理系统”——基于管理系统。该系统适用于一些
中
小型宾馆的管理应用, 本系统采用用户管理,客房管理,房客预定等应用,给广大用户带来了很大的便利。本系统具有以下功能: 1)用户管理,该功能用于管理使用该系统的用户,以及按模块进行权限的分配。 2)房客管理,主要包括房客登记、补交押金、房客换房和房客退 3)预订管理,主要包括预定房间、预定转入住和类别。取消预定。 4)客房管理,主要包括客房信息、编辑客房和客房内的物品。 (自己完成) 开发工具:
C#
、SQL Server 2000。 private void loading1_Load(object sender, EventArgs e) { while (dr.Read()) {
comboBox
1.Items.Add(dr["userIdetity"].ToString()); } this.button1.Visible = false; this.button2.Visible = false; timer1.Interval = 1000; timer1.Start(); label4.Text = System.DateTime.Now.ToString(); } private void
comboBox
1_
Selected
Index
Change
d(object sender, EventArgs e) { if (
comboBox
1.Text == "前台服务员") { button1.Text = "登录前台系统"; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "select username from userManagement where userIdetity=@userIdetity "; cmd.Parameters.Add(new SqlParameter("@userIdetity",
comboBox
1.
Selected
Item.ToString())); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) {
comboBox
2.Items.Add(dr["username"].ToString()); } dr.Close(); } else if (
comboBox
1.Text == "后台总经理") { button1.Text = "登录后台系统"; cmd.CommandText = "select userName from userManagement where userIdetity=@userIdetity "; cmd.Parameters.Add(new SqlParameter("@userIdetity",
comboBox
1.Text )); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) {
comboBox
2.Items.Add(dr["userName"].ToString()); } }
Winform
ComboBox
如何独立绘制下拉选项的字体颜色
众所周知,cbo1.ForeColor会同时
改变
cbo1.Text和下拉选项字体颜色。 独立绘制下拉选项字体颜色,ForeColor 只对 cbo1.Text 颜色有效的办法,示例: private void cb7_DrawItem(object sender, DrawItemEventArgs e) { DrawCboItems(sender, e); } private void cb7_
Selected
Index
Change
d(object sender, EventArgs e) { SetCboTextColor(sender); } private void SetC
C#
编写的图书管理系统源代码
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 图书管理系统 { public partial class 登录窗口 : Form { //public static string ConnectionString = "Server=(local);database=图书管理库;uid=sa;pwd=1234"; //sql server 混合模式 // public static string ConnectionString = "Server=(local);Integrated Security=SSPI;database=图书管理库"; //windows模式 public string strSQL; public SqlConnection myConnection; public SqlCommandBuilder sqlCmdBld; public DataSet ds = new DataSet(); public SqlDataAdapter da; public int num=0; private DataTable myTable; private DataRow myRow; public static string strUser; public static string strPassword; // public static string strDepartment; public static bool login_flag = false; public 登录窗口() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Close(); } private void 登录窗口_Load(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "select * from 用户表 "; da = new SqlDataAdapter(strSQL, myConnection); ds.Clear(); da.Fill(ds, "用户表"); //////动作 myTable = ds.Tables["用户表"]; for (int i = 0; i < myTable.Rows.Count; i++) {
comboBox
1.Items.Add(myTable.Rows[i]["用户名"].ToString().Trim()); } } private void button1_Click(object sender, EventArgs e) { linkdatabase link = new linkdatabase(); //实例化 myConnection = new SqlConnection(link.connectionstring()); //实例化连接 strSQL = "sele
C#
110,534
社区成员
642,576
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章