Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Grids > Winforms Grids

Winforms Grids Discussion related to grid controls of all types for Winforms

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2009, 3:18 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: May 2008
Posts: 77
Reputation: 24
jamie123 is on a distinguished programming path ahead
Default dgv checkbox problem

I'm using a datagridview on vs2008 programming with vb.net. The datagridview is populated from a sql server 2005 database. There is a checkbox for one of the columns (it's of boolean type). I used the following code to determine whether the checkbox is being selected or unselected, it worked in my other programs, but in my current program, it ALWAYS shows the checkbox as having a false value, not sure what's going on..

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim dgCB As New DataGridViewCheckBoxCell
Dim Value As Boolean
Dim dgCBTax As New DataGridViewCheckBoxCell
Dim ValueTax As Boolean
If e.RowIndex = -1 Then
Exit Sub
End If
Value = DataGridView1(e.ColumnIndex, e.RowIndex).Value.ToString()
dgCB = CType(DataGridView1(e.ColumnIndex, e.RowIndex), DataGridViewCheckBoxCell)

If e.ColumnIndex = 2 then
If Value = False And dgCB.EditingCellValueChanged Then
ID = DataGridView1(0, e.RowIndex).Value.ToString
ElectronicClaimTableAdapter.UpdateSendtoTrue(ID) 'Updates value of checkbox column to true since it was previously false, and clicked
MsgBox("hello")
Else
ID = DataGridView1(0, e.RowIndex).Value.ToString
ElectronicClaimTableAdapter.UpdateSendtoFalse(ID) 'Updates value of checkbox column to false since it was previously true, and clicked
MsgBox("goodbye")
End If
End If


End Sub

any help would be greatly appreciated, thanks! (I know there are inefficiencies in the code above, but I don't understand why the checkbox is always reporting a value of false)

EDIT: I've found the solution, BUT, it makes my form laggish, i'll explain why. I refilled the dataset after the condtional statements, example (all of below is an excerpt from above except bolded text:

If Value = False And dgCB.EditingCellValueChanged Then
ID = DataGridView1(0, e.RowIndex).Value.ToString
ElectronicClaimTableAdapter.UpdateSendtoTrue(ID) 'Updates value of checkbox column to true since it was previously false, and clicked
MsgBox("hello")
Me.ElectronicClaimTableAdapter.Fill(EyeBaseDataSet .ElectronicClaim)


This updates the datagridview, and now the correct messageboxes appear when checked on or checked off, but, everytime i check, the scroll bar resets to the top. It is very annoying to check a checkbox with the scrollbar halfway down, and then check a box, and have it reset your scroll position, how could this be avoided?

Thank you!

Last edited by jamie123; 06-11-2009 at 6:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 12:59 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.