如何对Gridview采取行动;按钮事件 [英] How to Act on Gridview;s Button Event

查看:56
本文介绍了如何对Gridview采取行动;按钮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
                       
if (e.RowIndex >= 0 && e.ColumnIndex==4 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() ==  typeof(DataGridViewButtonColumn))
              {
                  DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                  dataGridView1.Rows.Add(row);
               }
        }



我正在使用上面的代码在按钮点击的Gridview中生成另一行,这对按钮点击工作正常但是问题是我做组合框单击或文本框文本更改(组合框和文本框也包括在Gridview的行中带按钮)自动出现一个新行而不运行上面的代码。我出现的新行如何没有做任何代码


I am using the above code to generate another row in Gridview on button click which is working fine on button click but the problem is when i do Combo box click or do textboxes text change (Comboboxes and Textboxes are also include in Gridview's Row with button) a new row appear automatically without the running of above code. how new row i appearing i didnt do any code

推荐答案

很难理解你的问题 - 如果我错了,请原谅我:但你正在过滤

e.ColumnIndex == 4 typeof(DataGridViewButtonColumn)两者都不能为真你的文本框组合框...不?
Hard to understand your question - so excuse me if I'm wrong: but you are "filtering" for
e.ColumnIndex==4 and typeof(DataGridViewButtonColumn) both can't be true for your textboxes comboboxes... No?


这篇关于如何对Gridview采取行动;按钮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆