Which is best control to use?

  • Thread starter Thread starter MM
  • Start date Start date
M

MM

Hi,

I have a data structure like this:-
Param1 Param2 Param3 etc
[0] 0 15.2 10.0
[1] 5 8.4 50.0
etc.
Basically I need a spreadsheet like control to display/modify this data.
The DataGrid control seems to have a strong bias to db stuff (or am I
wrong on this?). Does C# have just a simple grid control? Thanks, matthew.
 
Yes, you can use the grid control.

However, I would recommend using the Listview control, and setting the
view mode to details. Here is a simple example of how to populate a
listview control with the data structure above.

ListView curData = new ListView();
curData.View = System.Windows.Forms.View.Details;
curData.GridLines=true;
curData.Location = new Point(5,5);
curData.Size=new Size(200,200);

curData.Columns.Add("Param1",50,System.Windows.Forms.HorizontalAlignment.Center);
curData.Columns.Add("Param2",50,System.Windows.Forms.HorizontalAlignment.Center);
curData.Columns.Add("Param3",50,System.Windows.Forms.HorizontalAlignment.Center);

/*
Of course you will need to read this data from an source,
so you will be using the looping mechanism to create each row.
*/
ListViewItem curItem = new ListViewItem("0");
curItem.SubItems.Add("15.2");
curItem.SubItems.Add("10.0");

curData.Items.Add(curItem);

curItem = new ListViewItem("50");
curItem.SubItems.Add("8.4");
curItem.SubItems.Add("50.0");

curData.Items.Add(curItem);

this.Controls.Add(curData);
 
Of course you could also use the Excel sheet object and minuplate the
data as excel data ... just another idea :)

Issam Qadan
 

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

Back
Top