need grid-style control

  • Thread starter Thread starter Zytan
  • Start date Start date
Z

Zytan

I know there's a DataGridView, but I think that's for synching the GUI
to data in a SQL database. Is there anything simple like a slightly
more complicated list box? Even if I could use a listbox of strings
which align the text into multiple columns with tabs I would be happy.

Zytan
 
I can see there's several 3rd party grid controls. Any of them
recommended?

I just need something simple. I have an array of elements, and each
element has several pieces of data. I'd like to show them row aligned
and column aligned.

Zytan
 
ListView in the "details" view would seem to fit the description; but
don't be fooled by the name; DataGridView will work for any data that
fits the standard pattern (which reflection does for you 9 times out
of 10), and can be used very successfully bound to properties on
regular classes. Or irregular classes if you don't mind writing your
own view ;-p

The advantage of DataGridView over ListView is that you don't need to
fill the columns yourself - just hand it a list and hey presto: data.
It can also be editable etc.

Marc
 
Just out of interest : have you tried:

dataGridView1.DataSource = myArray;

?

Since arrays implement IList, this will give you one row per element;
and likewise reflection will provide the columns based on public
properties (with AutoGenerateColumns=true, which is the default). If
you don't want *all* the properties you can add the columns manually
quite easily.

Marc
 
Just out of interest : have you tried:
dataGridView1.DataSource = myArray;

No, I just did now with an array of 3 strings, and it shows the length
of each string. It must do this because Length is a property of the
string.
Since arrays implement IList, this will give you one row per element;
and likewise reflection will provide the columns based on public
properties (with AutoGenerateColumns=true, which is the default).

Yup, so that's what is causing this.
If
you don't want *all* the properties you can add the columns manually
quite easily.

Thanks, Marc! I will toy with this for a bit.

Zytan
 
ListView in the "details" view would seem to fit the description;

No, I don't want a list shown in a grid pattern. I already have 2D
data, like an excel sheet of data, and I want to show it in the grid.
The advantage of DataGridView over ListView is that you don't need to
fill the columns yourself - just hand it a list and hey presto: data.

Yes, very powerful!
It can also be editable etc.

Yup. It must be user-editable. I think I'll turn that off. I just
want to show the data, not allow someone to change it.

Zytan
 
Back
Top