checkbox in datagridview c#

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: May 2006
Posts: 29
Reputation: brainbox is an unknown quantity at this point 
Solved Threads: 1
brainbox's Avatar
brainbox brainbox is offline Offline
Light Poster

checkbox in datagridview c#

 
0
  #1
Nov 26th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: checkbox in datagridview c#

 
0
  #2
Nov 27th, 2006
Originally Posted by brainbox View 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.
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.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 29
Reputation: brainbox is an unknown quantity at this point 
Solved Threads: 1
brainbox's Avatar
brainbox brainbox is offline Offline
Light Poster

Re: checkbox in datagridview c#

 
0
  #3
Nov 28th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: checkbox in datagridview c#

 
0
  #4
Nov 28th, 2006
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.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 29
Reputation: brainbox is an unknown quantity at this point 
Solved Threads: 1
brainbox's Avatar
brainbox brainbox is offline Offline
Light Poster

Re: checkbox in datagridview c#

 
0
  #5
Dec 3rd, 2006
Originally Posted by hollystyles View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC