Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Problem while clicking Buttons
 

Problem while clicking Buttons

Hi All,
I have one datagrid(Win Forms)where i will create two columns dynamically(run time) as Edit and Delete and also i am loading two buttons as same name. Here i am assigning datasource as data table. If i click onEdit & Delete Buttonssome times it fires the event (CellContentClick). In some time it will not at all fires that event. Please help me in this. I have written code like this. Here upto 14 columns data will be loaded programatically(not dynamically).

For Loading columns and Buttons code is:

DataGridViewButtonColumn dtgvEdit = new DataGridViewButtonColumn();
dtgvEdit.Name =
"btnEdit";
dtgvEditHeaderText =
"Edit";
dtgvEdit.Text =
"Edit";
dtgvEdit.UseColumnTextForButtonValue =
true;
gridview.Columns.Insert(15, dtgvEdit);


DataGridViewButtonColumn dtgvDelete = new DataGridViewButtonColumn();
dtgvDelete.Name =
"btnDelete";
dtgvDeleteHeaderText =
"Delete";
dtgvDelete.Text =
"Delete";
dtgvDelete.UseColumnTextForButtonValue =
true;
gridview.Columns.Insert(16, dtgvDelete);



In CellContent click i have written code like this:

private

void dtgvExperience_CellContentClick(object sender, DataGridViewCellEventArgs e)

{

if (e.ColumnIndex==15 && e.RowIndex != -1)

{


exp.EmployerName = dtgvExperience.Rows[e.RowIndex].Cells[0].Value.ToString();

}

}
Ganapatisb  Monday, September 14, 2009 6:19 AM
Hi Ganapatisb,

Could you please package the code to a small project in which the issue can be reproduced and email the package to me : alala666888@email.com. I have testedthe similar code but did not meet any issue.

Regards,
Aland Li

Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Wednesday, September 16, 2009 5:55 AM

You can use google to search for other answers

Custom Search

More Threads

• Can no longer add tab pages
• Error message when switchign between designer and code view
• Different form views on one form
• The RootDesigner Can't work with generic
• Status Strip Blacking Out Issue on Windows Vista
• Windows Form Designer not populating event drop-down menu
• How to put a pop-up box control into Toolbox?
• How to assign string resource to user control's property at design time?
• How do make my own TabControl
• How to call the Form Load from within the form