in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Showing multiple columns as data when using MultiColumnDictionary

Last post 10-26-2007 12:50 PM by Jon1. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-25-2007 3:31 PM

    • Jon1
    • Not Ranked
    • Joined on 04-03-2006
    • Posts 3

    Showing multiple columns as data when using MultiColumnDictionary

    I have an application that contains a C1FlexGrid with a column containing codes that is suitable for using a combo box with a drop-down list and a multicolumn dictionary.  The multiple columns are the code and the corresponding description of that code, which is stored in a database table (this is an unbound grid).  I create a DataMap by creating a new MultiColumnDictionary and reading the codes and their corresponding descriptions from the database and then set the flexgrid column's DataMap property to that MultiColumnDictionary.  This works fine, and the drop-down list appears very nicely formatted.  My problem is that I would like to display both the code (first column) and the description (second column) together in the grid when the cell is not in edit mode, separated by a suitable delimiting character.  However, when a DataMap is in effect, I can only get one column or the other to display in the grid, but not both when the cell is not in edit mode.  Is there any way to display both columns using the DataMap.  If not, is there an alternative?

    Thanks.

    jon 

  • 10-26-2007 10:22 AM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 515

    Re: Showing multiple columns as data when using MultiColumnDictionary

    You can handle this in the OwnerDrawCell method.  In the sample below it retrieves all column data from map (a MultiColumnDictionary), using the column 2 grid data as the key, and replaces the column separator with a colon. 

     

    C1FlexGrid1.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw

    Private Sub C1FlexGrid1_OwnerDrawCell(ByVal sender As System.Object, ByVal e As C1.Win.C1FlexGrid.OwnerDrawCellEventArgs) Handles C1FlexGrid1.OwnerDrawCell
        
    If e.Col = 2 Then
             
    Try
                
    e.Text = map.Item(C1FlexGrid1.Item(e.Row, 2)).Replace(C1FlexGrid1.ClipSeparators.Chars(0), ":")          
              
    Catch ex As Exception

              
    End Try
         
    End If
    End Sub

     

    Regards,
    Greg L

  • 10-26-2007 12:50 PM In reply to

    • Jon1
    • Not Ranked
    • Joined on 04-03-2006
    • Posts 3

    Re: Showing multiple columns as data when using MultiColumnDictionary

    Thanks, Greg.  That does exactly what I want to do.

    jon 

Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.