in

C1 Community

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

DataMap on Specific Row and Column

Last post 10-04-2007 4:56 PM by arockwel. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-02-2007 4:49 PM

    DataMap on Specific Row and Column

    Using a DataMap is great when every row in a column uses the same data. This is an example of what I've typically used when loading the grid:

            strSql = "SELECT * FROM Employee ORDER BY FullName "
            sqlCom = New SqlCommand(strSql)
            sqlCom.Connection = SQLCon
            sqlSearch = sqlCom.ExecuteReader()       

            Dim empMap As Specialized.ListDictionary = New Specialized.ListDictionary()
            

            If sqlSearch.HasRows Then
                While sqlSearch.Read()
                    empMap.Add(sqlSearch!EmployeeID, sqlSearch!FullName)
                End While
                vsFlexGrid.Cols("Employee").DataMap = empMap
            End If

            
    sqlSearch.Close()

    However, how do you handle rows that have different combobox data for the same column? For example, I have two columns: Department and Employee. When you pick a Department all the associated Employees with that specific Department should be loaded into the Employee column’s combobox on that specific row. Another row may have a completely different set of employees. How do I set and retrieve the associated Employee IDs using a DataMap in this type situation while keeping the text portion visible when I move off that row? I imagine I need to use BeforeEdit in some fashion for this to work correctly but am not sure how to go about this.

    Any help would be much appreciated. Thanks....
    Filed under: ,
  • 10-04-2007 3:51 PM In reply to

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

    Re: DataMap on Specific Row and Column

    >> However, how do you handle rows that have different combobox data for the same column?

    You can accomplish this if you use a combo box control as the column editor.  You could have multiple combo boxes each bound to a different dataset and customize which rows get which combo box for column X (by switching the column editor property at runtime).  Or you can use 1 combo box as the column editor and change its datasource at runtime depending on which row you are editing.  When you change the editor or datasource the data already set in the column will not change, unlike with DataMaps.

     

    Hope that helps,
    Greg

    Filed under: , ,
  • 10-04-2007 4:56 PM In reply to

    Re: DataMap on Specific Row and Column

    Thanks for that information. I'll look into that option...

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