|
-
Nov 10th, 2003, 02:34 PM
#1
Thread Starter
Hyperactive Member
Customizing the properties of a datagrid
Is it possible to arrange the columns in a datagrid? For instance I have a time entry form where time is entered into a database.
There is a datagrid at the bottom of the form that shows the newly entered data. Since I am creating a weekly time sheet entry program I would like the data in the datagrid to appear the same way it does in the form.
For instance the form has these fields in this order
[EmployeeNumber], [JobNumber], [PhaseCode], [Mon], [Tue], etc.
I am not sure how the datagrid chooses its column order but it looks random to me. Is there a way for me to control this?
-
Nov 10th, 2003, 08:04 PM
#2
Frenzied Member
Its not random. It does it on a first come first serve basis. It sets it up base on the way its set up in the database. You can override that behaviour by mapping the columns in the DB to the datagrid.
-
Nov 11th, 2003, 11:04 AM
#3
Thread Starter
Hyperactive Member
Its not random. It does it on a first come first serve basis. It sets it up base on the way its set up in the database.
I don't understand. If it is based on the way the database is set up everything should be in the proper order. It's not. I don't even see a pattern to it.
You can override that behaviour by mapping the columns in the DB to the datagrid.
I didn't find anything useful in the Help to get me started on this so I am on my way to Google. If anyone has a link or could provide a little more information about doing this I would be grateful. Thanks!
-
Nov 11th, 2003, 11:13 AM
#4
The order is the same as the properties come during reflection, how that gets ordered I don't know. But to control how the datagrid displays data you need to create a TableStyle and assign it a mapping name that matches a datasource that you will pass in. Just add the various Columns to the TableStyle and order them how you want at designtime from the properties dialog generally to the right.
-
Nov 11th, 2003, 03:03 PM
#5
Thread Starter
Hyperactive Member
Once again I thank you Edneeis. It took me a while to figure out how to manipulate the columns because it is not all the intuitive but I finaly did get it hammered out.
For anybody following this thread. Here is a link to a page, which will help you get your head around this concept.
DataGrid101 - Using Windows.Forms DataGrid
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
|