With a datagrid, if you set the column width of the columns you want hidden
to 0 or you can just not provide a ColumnMapping for them. Check out this
class
http://www.knowdotnet.com/articles/cgrid.html - the code that's
included with it will show you how to do most anything you will want to do
with a grid.. There's also a NullText property you can set for each Column
that has DataGridColumnStyle that will substitute the value you specify
instead of showing (Null) although frm the sound of yoru entire question,
you don't want a value there, you want the column hidden.
Anyway, as far as 'best' goes, that depends on a lot of things but as far as
a 'list of clickable data', actually, the grid probably isnt' that great of
a choice. Out of the box it has sorting capabilities, but if you bind to a
DataView instead of a DataTable, it's easy enough to implement through code.
The reason I say this is b/c if you only have one column in a list, the grid
has a lot of extra hoops you need to jump through to get a given value that
a ListBox or ComboBox doesn't (not that I'm saying it's 'hard', I just think
that for clickable funcionality in a list - that the ListBox or ComboBox is
probably a better choice in most cases. A Listbox is probably a better
choice for a single column list b/c you can just reference what they click
with SelectedItem and SelectedValue (remember to set the DisplayMember and
ValueMembers - this way, you can show one value but use a different one -
something which is a pain to do in a grid)
"Saber" <saber[.AT.]oxin.ir> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I did a lot of searches and read something about
datagrids. But I couldn't find the answer of my simple
question, how can I show only my desired columns of
a table? for example I wrote this sql query:
OleDbDataAdapter1.SelectCommand.CommandText = & _
"Select illNameE From tblIllness"
OleDbDataAdapter1.Fill(DsIllness1)
But in my datagrid, I get (null) for other ccolumns instead
of hiding undesired columns.
Another question: Is datagrid best choice in windows form
to show a list of "clickable" data?
TIA
--
Saber S.
http://maghalat.com