积极答复者
为什么传递事件的参数无效?

问题
-
在WINFORM窗体上添加了一个toolstripCombox控件,当控件中的下拉选项发生变化时,偶选择使用TextChange事件,这个事件有一个传递的参数EventArgs e,偶用switch判断Text的值,e.ToString().Trim()能否代表这个Text,写的这段代码,怎么就运行不了,当值发生变化时DataGridView控件中无数据显示,求解:\
private void ToolStripCombox_TextChanged(object sender,EventArgs e) { switch (e.ToString().Trim()) { case "未关联出入库数量占总出入库数量的百分比": SqlConnection thisconnection = new SqlConnection("server=192.100.3.3;database=AIS20090527152941;uid=sa;pwd=;"); string Command = @"SELECT [未关联出入库数量占总出入数的百分比]=SUM(CASE WHEN b.FSourceBillNo='' then b.FQty ELSE 0 END)/SUM(b.FQty) FROM ICStockBill a LEFT OUTER JOIN ICStockBillEntry b ON a.FInterID=b.FInterID WHERE a.FTranType<>10 AND a.FTranType<>29 AND a.FTranType<>40 AND a.FTranType<>41 AND a.FTranType<>43 AND a.FTranType<>100 AND a.FDate>=CASE WHEN DAY(GETDATE())>=28 THEN CONVERT(VARCHAR(7),GETDATE(),120)+'-28' ELSE DATEADD(MONTH,-1,CONVERT(VARCHAR(7),GETDATE(),120)+'-28') END AND a.FDate<CASE WHEN DAY(GETDATE())>=28 THEN DATEADD(MONTH,1,CONVERT(VARCHAR(7),GETDATE(),120)+'-28') ELSE CONVERT(VARCHAR(7),GETDATE(),120)+'-28' END AND a.FCancellation=0"; SqlCommand cmd = thisconnection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = Command; cmd.CommandTimeout = 0; SqlDataAdapter Adapter = new SqlDataAdapter(); Adapter.SelectCommand = cmd; DataSet ds = new DataSet(); Adapter.Fill(ds); this.dataGridView1.DataSource = ds.Tables[0]; break; } }
- 已编辑 .net小痞子 2010年1月4日 1:25 格式太丑
- 已移动 Sheng Jiang 蒋晟Moderator 2010年1月4日 23:02 .Net基础类库问题 (发件人:Visual C#)
答案
-
这个事件的e代表的不是事件所传递的参数值么?
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.control.textchanged.aspx
http://feiyun0112.cnblogs.com/- 已标记为答案 .net小痞子 2010年1月4日 3:57
全部回复
-
这个事件的e代表的不是事件所传递的参数值么?
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.control.textchanged.aspx
http://feiyun0112.cnblogs.com/- 已标记为答案 .net小痞子 2010年1月4日 3:57