DataGridView / DataGrid help needed
-
I have a program that displays data in a DataGridView in C# (but if you are only familiar with the DataGrid, please read on because any advice you have will still be applicable). The DataGridView is bound to a SQL Server table with a typed DataSet. I need to do a few things that I'm having difficulty with, and I'm hoping someone can point me in the right direction. 1) Some columns of the database table contain numbers, like 0, 1, 2, that represent things. For example, in one column, 0 and 1 in the database table should be shown as false and true in the DataGridView. In another case, a small range of numbers in the database table should be represented as a corresponding value from a list of strings. In the DataGridView, these columns are combo box columns that are NOT bound to any data source (I enumerate the possible combo box values when I create the DataGridView). Currently they contain the numbers from the database. How can I get them to contain the corresponding strings? I tried using the CellFormatting and CellParsing events, but they don't work properly due to the many DataError events caused by changing the cell values from short or int (as in the database table column) to string (as in FALSE/TRUE). Are the ValueMember and DisplayMember attributes of the column of any value to me? Do I have to create an unbound column? If so, how do I keep that column sorted as the user sorts the bound columns in the DataGridView? 2) One combo box column of the table gets its combo values loaded from the keys of another table (not bound to it, but I do it manually). But if my table has "foobar" in a column and the keys from the other table that get loaded into the combo box include "FOOBAR" (upper case), I get a data error event. Is there some way to make it case insensitive? Thanks for any help. -- modified at 17:24 Saturday 18th February, 2006