-
April 16th, 2010, 09:12 AM
#1
[RESOLVED] Create table in Windows.Forms?
I would like to create a simple quick dynamic table in my Windows.Form consisting of three fixed columns and rows that are added at run-time. I have tried working with DataSets and TableLayout but I dont understand how I can add rows dynamically and I couldnt get my head around it! What is the best method to use and could you give an example of how I can do this please?
-
May 18th, 2010, 01:56 PM
#2
Re: Create table in Windows.Forms?
DataGridView
DataGridView.Rows.Add();
DataGridView.Rows[].SetValues();
Cheers!
-
May 18th, 2010, 04:00 PM
#3
Re: Create table in Windows.Forms?
Is the grid filled by the DataTable from a Database ?
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
May 18th, 2010, 04:12 PM
#4
Re: Create table in Windows.Forms?
You can databind the control if you want. The last two methods I provided as examples are for dynamic entry.
dg.Rows.add() adds as many rows as you would like, and
dg.Rows[].SetValues places an array of values into a row
DataGridView dg = new DataGridView();//or create one visually in VS
this.Controls.Add(dg);
dg.Rows.Add(1);
dg.Rows[0].SetValues(new string[] {"Col1Value","Col2Value","Col3Value"});
You can also reference individual cells using dg[col,row] like dg[0,0].Value = "FirstRowFirstColumn");
google my earlier examples for more info and let me know if you have any questions.
Cheers!
-
May 28th, 2010, 03:23 AM
#5
Re: Create table in Windows.Forms?
Thank you, Ill try that
Last edited by stephsh; May 28th, 2010 at 03:35 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|