locked
Application rewrite - datagridview multi-selects & column wrapping (not text wrapping) RRS feed

  • Question

  • I have, what seems like, a complicated request. But I WAS able to acomplish this in a visual basic 6 application years ago and this is currently implented in our delphi 6 app.  But need help rewriting this in c#.

    I have 2 needs here really and I'm not sure the best way to explain this.

    #1. I am going to run a few SELECT statements. (These aren't the actual queries.. just getting the idea to you)
            SELECT id, comment FROM units where area = '1'
            SELECT id, comment FROM units where area = '2'
            SELECT id, comment FROM units where area = '3'
    I need to display each set of records returned by the individual queries, together, in one datagridview, horizontally.
    As such:
    query 1           query 2           query 3
    id, comment    id, comment    id, comment
    id, comment    id, comment    id, comment
    id, comment    id, comment    id, comment
    id, comment    id, comment    id, comment
    id, comment    id, comment    id, comment

    Make sense? I am rewriting an app for work in visual studio that was originally created in delphi 6. A screenshot of the old app can be
    seen here: http://www.cts-america.com/images/content/prod/full/v6_CAD_main.jpg (You may need to click the image to get it into focus)
    The grid I am attempting to duplicate is on the bottom. Column headers of "DISTRICT"

    #2. The second problem I am having, is displaying this records without the vertical scroll bar - "wrapping" the columns.

    Example:
    If I have 9 records, but only 6 are in view, the user will have to use the vertical scroll bar to see the others. I want to prevent this. I want the records out of view to "wrap" into a new column. Thus the vertical scroll bar will never appear. The datagridview height will be adjustable by handles, so if the height of the datagridview changes, it should adjust where necessary.

    Each record will have 2 fields.

    Instead of this:                                                   I want this:

    Header 1        Header 2                              Header 1                       Header 2
    1a 1b             1a 1b                                    1a 1b       7a 7b            1a 1b
    2a 2b             2a 2b                                    2a 2b       8a 8b            2a 2b
    3a 3b             3a 3b                                    3a 3b       9a 9b            3a 3b
    4a 4b             4a 4b                                    4a 4b                            4a 4b
    5a 5b                                                          5a 5b                                 
    6a 6b                                                          6a 6b
    7a 7b
    8a 8b
    9a 9b


    Again, these were all accomplished in both visual basic 6 (years ago) and then Delphi 6/2007. Now we need to recreate it in visual studio. Any insight would be incredibly appreciated. Thanks ahead of time.
    Monday, August 18, 2008 1:37 AM

Answers

  • Ah, you didn't mention drag and drop.  That can be done with the WPF listboxes into anything else, but you have to specify what the object is that gets copied. 

    Unfortunately, the DataGrid control for WPF hasn't been released yet, but there's a third party control out there somewhere.  I imagine it also works from to a WinForms datagrid, but I haven't tried it.  
    • Edited by cncarson Monday, August 18, 2008 10:26 PM ya'rgl'e' ' '
    • Marked as answer by jack 321 Friday, August 22, 2008 10:24 AM
    Monday, August 18, 2008 4:14 PM

All replies

  • Easy - don't use a DataGridView.

    Use a horizontal stack panel with a series of dockpanels, each containing the Header docked at the top and a ListBox.  Use a DataTemplate for the items in the ListBoxes to get the '1a 1b' behavior, and set it to tile.

    edit:  If you can't get buy-in to use WPF for the entire UI, then you can write that particular item as a WPF control and host it in a WinForm.
    • Edited by cncarson Monday, August 18, 2008 5:57 AM urghl
    Monday, August 18, 2008 5:50 AM
  • I don't think I can use drag and drop in that case, can I? I need to be able to drag a cell from this grid/"listbox" to another datagridview, among other typical datagrid properties.

    Monday, August 18, 2008 2:35 PM
  • Ah, you didn't mention drag and drop.  That can be done with the WPF listboxes into anything else, but you have to specify what the object is that gets copied. 

    Unfortunately, the DataGrid control for WPF hasn't been released yet, but there's a third party control out there somewhere.  I imagine it also works from to a WinForms datagrid, but I haven't tried it.  
    • Edited by cncarson Monday, August 18, 2008 10:26 PM ya'rgl'e' ' '
    • Marked as answer by jack 321 Friday, August 22, 2008 10:24 AM
    Monday, August 18, 2008 4:14 PM
  • Thanks for your replies. I am going to play around with a few different ways and see what I can come up with.

    If anyone else has a recommendation, I am all ears. Thanks
    Monday, August 18, 2008 6:28 PM