Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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?
Avatar of John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou
Flag of Greece image

1.What do you mean with Blank Value
2.Set the ThreeState of datagridviewCheckBoxColumn to false
me.DatagridviewCheckBoxColumn.ThreeState=False
Otehr Question ..Isn't the column contains CheckBoxes A DatagridView CheckBoxColumn?
Avatar of RIAS

ASKER

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.
 
Avatar of RIAS

ASKER

Blank Value is dbnull value
I think that the column add method requires string,string
Me.datagriview1.Columns.Add("ColumnName" as string,HeaderText as string)
Avatar of RIAS

ASKER

But how do you add a object column to datatable.Isn't this the way
dtTemp.Columns.Add("Selection", GetType(Object))  
a sory it is a datatable...
ASKER CERTIFIED SOLUTION
Avatar of John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
also try
Me.DataGridView1.Sort(Me.DataGridView1.Columns("SortCol"), System.ComponentModel.ListSortDirection.Ascending)
Avatar of RIAS

ASKER

Cheers!!!