| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4137 人关注过本帖
标题:C#事件调用
取消只看楼主 加入收藏
chenweichao2010
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2008-10-19
收藏
 问题点数:0 回复次数:3 
C#事件调用
请求各位给我解答一下!(事件调用)
private void txtInput_TextChanged(object sender, EventArgs e)
        {
            String strInput = txtInput.Text.ToString().Trim();
            SqlConnection myConnection = new SqlConnection

("server=localhost;database=ProductData;Trusted_Connection=yes;user id=;password=");
            SqlDataAdapter orderdet = new SqlDataAdapter("select

pId,pName,pModel,pUnit,pColor,pPurchasePrice,pMinAmount from Product where pId like '%" +

strInput + "%' or pName like '%" + strInput + "%'", myConnection);
            DataTable dt = new DataTable();
            orderdet.Fill(dt);
            dataProductBill.DataSource = dt.DefaultView;
            //dataProductBill_CellMouseDoubleClick(null,null);
        //想在这里调用dataProductBill_CellMouseDoubleClick()这个事件,但调用这个事件都没有反应的,可能是参数的问题吧!
        }




   private void dataProductBill_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                //获取DataGirdView中的值
                String strId = dataProductBill.CurrentRow.Cells["pId"].Value.ToString();
                String strName = dataProductBill.CurrentRow.Cells["pName"].Value.ToString();
                String strModel = dataProductBill.CurrentRow.Cells["pModel"].Value.ToString();
                String strUnit = dataProductBill.CurrentRow.Cells["pUnit"].Value.ToString();
                String strColor = dataProductBill.CurrentRow.Cells["pColor"].Value.ToString();
                String strPuchasePrice = dataProductBill.CurrentRow.Cells["pConsultPrice"].Value.ToString();
                String strMinAmount = dataProductBill.CurrentRow.Cells["pMinAmount"].Value.ToString();
                String strManufacturer = dataProductBill.CurrentRow.Cells["pManufacturer"].Value.ToString();
                String strRemark = dataProductBill.CurrentRow.Cells["pRemark"].Value.ToString();
                FrmProductInfo fr = new FrmProductInfo(strId, strName, strModel, strUnit, strColor, strPuchasePrice, strMinAmount, strManufacturer, strRemark);
                fr.Owner = this;               
                fr.ShowDialog();
                label3.Text = strContent.ToString ();
                label4.Text = strName;
                label5.Text = strName1;               
                fr.Dispose();
                fillData();         
            }
            catch
            {
                MessageBox.Show("没有可选商品!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
搜索更多相关主题的帖子: localhost where 
2008-10-25 16:14
chenweichao2010
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2008-10-19
收藏
得分:0 
[bo][un]shmilylee[/un] 在 2008-10-26 10:21 的发言:[/bo]


dataProductBill.CellMouseDoubleClick += new EventHandler(dataProductBill_CellMouseDoubleClick);

注册事件时写好+=按2次"tab"键就会帮你写好的!


谢谢你的指教!可是怎么会报错的啊!错误如下:

1.jpg (6.8 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2008-10-27 11:32
chenweichao2010
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2008-10-19
收藏
得分:0 
[bo][un]铲铲[/un] 在 2008-10-27 15:42 的发言:[/bo]

CellMouseDoubleClick事件所使用的委托是DataGridViewCellMouseEventHandler,该委托的构造如下:
public delegate void DataGridViewCellMouseEventHandler(object sender, DataGridViewCellMouseEventArgs e);

 ...



谢谢你的指教,那么准确来说,在我上面的那段程序中,我应该怎么使用呢?能明确点告诉我吗?谢谢
2008-10-28 12:05
chenweichao2010
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2008-10-19
收藏
得分:0 
[bo][un]铲铲[/un] 在 2008-10-27 15:42 的发言:[/bo]

CellMouseDoubleClick事件所使用的委托是DataGridViewCellMouseEventHandler,该委托的构造如下:
public delegate void DataGridViewCellMouseEventHandler(object sender, DataGridViewCellMouseEventArgs e);

 ...

那么在我上面那段程序中,该具体怎么应用呢?谢谢
2008-10-28 20:36
快速回复:C#事件调用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022410 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved