0

I am making a win form in C# and in a few places I need to have a table like this:

table

I'd like to have this on my form with fixed column names but allow the user to enter in data in any of the rows below the first row that contains column names.

I tried to get a TableLayoutPanel to work for this but I couldn't figure out how to control the column names within the table itself. I am trying to do this in sharpdevelop.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Baub
  • 723
  • 4
  • 21
  • 36

1 Answers1

0

It's pretty easy to do what you are wanting here.

  1. Open Visual Studio
  2. Create a new project
  3. Create a Winforms application
  4. In the 'Toolbox', select 'DataGridView' and add it to your form
  5. On the DataGridView (on the form), click the little arrow in the upper-right
  6. Select 'Edit Columns'
  7. In the dialog, click the 'Add' button
  8. Add your column name (NOTE: You cannot include punctuation or white space in the name)
  9. Under 'Header text', enter the same value you just did in step 8 (you can have white space and punctuation here)
  10. Click 'Add' once again
  11. Notice that now the column is visible in the 'Edit Columns' dialog
  12. Repeat for your other columns.

Here is a screen shot of what it should look like:

enter image description here

Just an FYI, the columns can be edited by default.

Brian
  • 5,069
  • 7
  • 37
  • 47