C#- Question about unbound Datagrid

J

jimcolli

In a Windows form, I am using an unbound
Datagrid object like a simple table with two
columns to display data like

1 string1
5 string2
11 string3


I want to eliminate the fixed row at the top
with column captions and the fixed column
at the left. Also, if either column is
selected with a mouse, I want the entire
row to be selected.

What I am doing now is the following:

Datatable mdt = new DataTable ("tablename");
mdt.Columns.Add (null, typeof(string) );
mdt.Columns.Add (null, typeof(string) );

mdt.Rows.Add(new object[]{"1", "string1"});
mdt.Rows.Add(new object[]{"5", "string2"});
mdt.Rows.Add(new object[]{"11", "string3"});

myDataGrid.SetDataBinding(mdt, "");

Does anyone know how I can make the entire
selected, and eliminate the fixed caption-row
and column?


Jim
 
J

jimcolli

In a Windows form, I am using an unbound
Datagrid object like a simple table with two
columns to display data like

1 string1
5 string2
11 string3


I want to eliminate the fixed row at the top
with column captions and the fixed column
at the left. Also, if either column is
selected with a mouse, I want the entire
row to be selected.

What I am doing now is the following:

Datatable mdt = new DataTable ("tablename");
mdt.Columns.Add (null, typeof(string) );
mdt.Columns.Add (null, typeof(string) );

mdt.Rows.Add(new object[]{"1", "string1"});
mdt.Rows.Add(new object[]{"5", "string2"});
mdt.Rows.Add(new object[]{"11", "string3"});

myDataGrid.SetDataBinding(mdt, "");

Does anyone know how I can make the entire
selected, and eliminate the fixed caption-row
and column?

By the way, I should add that I had considered using
a Listbox. The only problem is that I need access
to the information in each cell. The Datagrid
formats this nicely, while reading cell items
in the Listbox is messy, although I must
admit that using a Datagrid to display
a two-column unbound table is a little
like harnessing an elephant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top