943,829 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 79385
  • C# RSS
Nov 26th, 2006
0

checkbox in datagridview c#

Expand Post »
Hi Everyone

could anyone help me with the event handling behind a checkbox, which is one of the columns in datagridview. First of all i am adding this checkbox column to dataTable dt, which is the source of DataGridView1. However, i cannot make the checkbox to work, i.e. ifi click on it to check or uncheck it, then it does not activate at all.

The checkbox is added as follows in the dataTabke dt.

CheckBox chkbox = new CheckBox;
dr[4] = chkbox.visible = true;

where dr[4] is the fourth column of the row dr in dataTable dt.

Now, the problem is that it is showing the checkbox in the dataGridView1, whose source is DataTable dt, but i cannot get this checkbox to working, it doesnot do anything if i check or uncheck it, even when i add a checkbox event handler. This checkBox is to delete the relative row from the datagridview1, when selected.

Thanks for any help in advance.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
brainbox is offline Offline
29 posts
since May 2006
Nov 27th, 2006
0

Re: checkbox in datagridview c#

Click to Expand / Collapse  Quote originally posted by brainbox ...
Hi Everyone

could anyone help me with the event handling behind a checkbox, which is one of the columns in datagridview. First of all i am adding this checkbox column to dataTable dt, which is the source of DataGridView1. However, i cannot make the checkbox to work, i.e. ifi click on it to check or uncheck it, then it does not activate at all.

The checkbox is added as follows in the dataTabke dt.

CheckBox chkbox = new CheckBox;
dr[4] = chkbox.visible = true;

where dr[4] is the fourth column of the row dr in dataTable dt.

Now, the problem is that it is showing the checkbox in the dataGridView1, whose source is DataTable dt, but i cannot get this checkbox to working, it doesnot do anything if i check or uncheck it, even when i add a checkbox event handler. This checkBox is to delete the relative row from the datagridview1, when selected.

Thanks for any help in advance.
Would this have anything to do with the fact that arrays start at zero in vb.net? If not post the section of code you thinks contains the error.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Nov 28th, 2006
0

Re: checkbox in datagridview c#

Thanks very much for your consideration.

This question is related to c# forum, and if not mistaken i posted this to the correct forum. The question is that i cannot get the checkbox working in datagridview, i.e. if i click on it then it does not do anything that it should be doing. The dr[4] was only given to show that this is the cell of the dataGridView, in which i have the chekbox.

I hope you would be able to understand the question now.

Thanks & Regards

Sarah
Reputation Points: 10
Solved Threads: 1
Light Poster
brainbox is offline Offline
29 posts
since May 2006
Nov 28th, 2006
0

Re: checkbox in datagridview c#

You need to set the Checkbox AutoPostBack property to true if you want it to post back as soon as it's checked/unchecked, or you need an asp: button to click. with the button solution checkedChanged will fire server side for any checkboxes that have changed state since the last request.
Last edited by hollystyles; Nov 28th, 2006 at 10:02 am.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Dec 3rd, 2006
0

Re: checkbox in datagridview c#

You need to set the Checkbox AutoPostBack property to true if you want it to post back as soon as it's checked/unchecked, or you need an asp: button to click. with the button solution checkedChanged will fire server side for any checkboxes that have changed state since the last request.
Thanks a lot for your help

I have tired this "AutoPostBack" property for the checck box HOWEVER, i cannot find any such thing in Visual studio 2005, it may be the version of Visual Studio. It has AutoPost, but this did not work either. Please help me, if you know any alternative approach.

Thanks

Sarah
Reputation Points: 10
Solved Threads: 1
Light Poster
brainbox is offline Offline
29 posts
since May 2006
Aug 26th, 2010
0
Re: checkbox in datagridview c#
autopostback sounds like a web-based solution, but i'd wager that the question from mister brainbox was related to a c# windows app.
i have the same problem in my windows app in that when i tick the tickbox, the cellclick event fires, and processes the change as expected, but the tickbox stays unticked on the screen. and when i untick a ticked tickbox, the event fires and is processed, but the tickbox stays ticked. very puzzled.
if anyone knows how to deal with this and make the tickbox change when it is clicked, i'd be over the moon!
d.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dinelli is offline Offline
1 posts
since Aug 2010
Aug 26th, 2010
0
Re: checkbox in datagridview c#
You are right, the question was a C# winforms one, it was also posted nearly four years ago. Try to avoid resurecting old threads.

Is your checkbox column bound or unbound?
Reputation Points: 512
Solved Threads: 246
Nearly a Posting Virtuoso
Ryshad is offline Offline
1,260 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Retrieve Int Value from dataGridView
Next Thread in C# Forum Timeline: fileupload contol in c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC