Sorting a boolean column in datagridview +vb.net 2005 windows programming

Hi,
I am struggling on how to sort a boolean column in datagridview.
When grid is bound with datatable the column has no value in it.Now when I check the row the item value of the boolean column value  is true and when uncheck it the value gets false.
When the column is sorted it sorts by the false and blank value.This is a problem how do I make blank and false same when sorted.Any suggestions?
RIASAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
1.What do you mean with Blank Value
2.Set the ThreeState of datagridviewCheckBoxColumn to false
me.DatagridviewCheckBoxColumn.ThreeState=False
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Otehr Question ..Isn't the column contains CheckBoxes A DatagridView CheckBoxColumn?
0
RIASAuthor Commented:
Hi,
No its a not a checkbox column it is a

dtTemp.Columns.Add("Selection", GetType(Object))
so it has a false or true value as I didnt want he checkboxes to appear in the column I created a column like the above.
 
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

RIASAuthor Commented:
Blank Value is dbnull value
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
I think that the column add method requires string,string
Me.datagriview1.Columns.Add("ColumnName" as string,HeaderText as string)
0
RIASAuthor Commented:
But how do you add a object column to datatable.Isn't this the way
dtTemp.Columns.Add("Selection", GetType(Object))  
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
a sory it is a datatable...
0
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Other way is to sort in a default View before populate the datagridview...
Try the Function Below


ortDataTable(YourDataTable, B,"YourColumnName", True)
Private Function SortDataTable(ByVal dTable As DataTable, ByVal ColumnName As String, Optional ByVal OrderByAsc As Boolean = True) As DataView
Dim dView As New DataView(dTable)

If OrderByAsc Then
dView.Sort = ColumnName & " ASC"
Else
dView.Sort = ColumnName & " DESC"
End If

Return dView
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
also try
Me.DataGridView1.Sort(Me.DataGridView1.Columns("SortCol"), System.ComponentModel.ListSortDirection.Ascending)
0
RIASAuthor Commented:
Cheers!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.