Formatting datagrid??

I'm developing a multitier Vb.net application, so I'm using my datagrids to display arraylists, which are taken from the database...

The problem is, the datagrid just puts the columns in any order it feels like - I can't find anywhere a place where I can change the order of the columns... (eg instead of displaying 'SupplierID' first, it displays 'EmailAddress')

Also, how do you autoformat column widths, as in make the width of the column as wide as the longest entry...?

TIA

Comments

  • : I'm developing a multitier Vb.net application, so I'm using my datagrids to display arraylists, which are taken from the database...
    :
    : The problem is, the datagrid just puts the columns in any order it feels like - I can't find anywhere a place where I can change the order of the columns... (eg instead of displaying 'SupplierID' first, it displays 'EmailAddress')
    :
    : Also, how do you autoformat column widths, as in make the width of the column as wide as the longest entry...?
    :
    : TIA
    :

    Maybe this will help you. The columns will come in the order you put them.







    Set
    Also added a date here for example. Had some problems solving that myself...

    Hope this is what you were looking for!
  • Ole

    Thanks for your reply.

    Unfortunately, I'm not developing an ASP application - I need this for windows forms... Is there a similar way to do that for windows forms?
  • [b][red]This message was edited by zorgster at 2005-8-16 12:37:39[/red][/b][hr]
    [b][red]This message was edited by zorgster at 2005-8-16 12:36:52[/red][/b][hr]
    : Ole
    :
    : Thanks for your reply.
    :
    : Unfortunately, I'm not developing an ASP application - I need this for windows forms... Is there a similar way to do that for windows forms?
    :

    In the properties of the DataGrid look for TableStyles - click on '...'

    Press Add to add a TableStyle - rename it to something apt.(dgtsWorks)

    change the Mapping Name to the name of the table you are putting in the grid.

    Then click on the '...' by GridColumnStyles

    For each column you want to show in the grid (start with a zero width ID column if you have one) Add a new ColumnStyle (ie dgtcWorksDescription)

    Set the preferred Alignment, the Header text you want to see, the value to display if the underlying value is Null, the width, format, Mapping Name is the name of the field in your database, and ReadOnly (true/false).

    Repeat for all columns you want to display. It takes some adjustment - which you could do in the code module if you know where to look (dgtcWorkDescription.Width = 120 change to 140) - before you get it to look the way you want it to...

    I have a grid that I use for three different tables depending on user choice. I have three TableStyles setup in DataGrid properties. The mapping name decides which TableStyle is applied when you set the DataSource to the specific DataTable (whether you bind it as a DataTable or Table(0) in a DataSet... you can also set different row colours and behaviour depending on the Table you bind to the DataGrid...

    Hope that is what you are trying to achieve...





  • [b][red]This message was edited by jbassmanp at 2005-9-23 8:30:57[/red][/b][hr]
    : [b][red]This message was edited by zorgster at 2005-8-16 12:37:39[/red][/b][hr]
    : [b][red]This message was edited by zorgster at 2005-8-16 12:36:52[/red][/b][hr]
    : : Ole
    : :
    : : Thanks for your reply.
    : :
    : : Unfortunately, I'm not developing an ASP application - I need this for windows forms... Is there a similar way to do that for windows forms?
    : :
    :
    : In the properties of the DataGrid look for TableStyles - click on '...'
    :
    : Press Add to add a TableStyle - rename it to something apt.(dgtsWorks)
    :
    : change the Mapping Name to the name of the table you are putting in the grid.
    :
    : Then click on the '...' by GridColumnStyles
    :
    : For each column you want to show in the grid (start with a zero width ID column if you have one) Add a new ColumnStyle (ie dgtcWorksDescription)
    :
    : Set the preferred Alignment, the Header text you want to see, the value to display if the underlying value is Null, the width, format, Mapping Name is the name of the field in your database, and ReadOnly (true/false).
    :
    : Repeat for all columns you want to display. It takes some adjustment - which you could do in the code module if you know where to look (dgtcWorkDescription.Width = 120 change to 140) - before you get it to look the way you want it to...
    :
    : I have a grid that I use for three different tables depending on user choice. I have three TableStyles setup in DataGrid properties. The mapping name decides which TableStyle is applied when you set the DataSource to the specific DataTable (whether you bind it as a DataTable or Table(0) in a DataSet... you can also set different row colours and behaviour depending on the Table you bind to the DataGrid...
    :
    : Hope that is what you are trying to achieve...
    :
    :
    :
    :
    :
    :
    This is exactly what I needed. Was getting ready to post a thread for help in reordering the field list in a DataGrid. Instead I did a search and this is perfect. If no one else says thanks I will. Thanks zorgster


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories