Results 1 to 5 of 5

Thread: Customizing the properties of a datagrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    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?

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    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!

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    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
  •  



Click Here to Expand Forum to Full Width