Home Forums WinForms controls Xceed Grid for WinForms MAster Detail and Wincombo Box Editor/Viewer

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16234 |

    (not able to attached/link image from local file system)

     I am still trying to come out of master child relation loop.

    Attached is the grid that i see with the code attached below.
    I have 2 tables for master and child data, master has a primary iendity key on col MAsterAID which is the primary col used for master-child relation ship with child table on col PArentID, which is not a primary key but of  integer data type.

    Also when tried to add wincombo box for field DBName, didnt work.

    With the existing code if i try inserting a record using the insertion row for master or detail then the grid goes blank.

    What care should be taken to prevent the above and display grid data properly.

     

     

    The code goes as below

     Dim internalDC As DataColumn
            Dim i As Integer
            Dim sztmpDS As DataSet

            Dim szPArentCol, szChildCol, szSubChildCol As String

            sztmpDS = New DataSet
            sztmpDS = getSmartDS()
            If sztmpDS.Tables.Count > 2 Then
                MsgBox(“Datasaet not Retrived, or Error Retriving Records”, MsgBoxStyle.Information, “Error with Dataset”)
                Exit Sub
            Else

            End If
            szPArentCol = “MasterAID”
            szChildCol = “ParentID”

     

          

            frmMain.GridControl1.BeginInit()
            Debug.Print(sztmpDS.Tables(0).TableName & ” – ” & sztmpDS.Tables(1).TableName)

            Dim dataRelate As New DataRelation(“MasterDetail”, _
                    sztmpDS.Tables(0).Columns(szPArentCol), _
                    sztmpDS.Tables(1).Columns(szChildCol), True)
            sztmpDS.Relations.Add(dataRelate)

     

            frmMain.GridControl1.SetDataBinding(sztmpDS, sztmpDS.Tables(0).TableName)

            Dim column1 As New Column(“Database”, GetType(String))
            frmMain.GridControl1.Columns.Add(column1)

            Dim viewer As New ComboBoxViewer(sztmpDS, sztmpDS.Tables(0).TableName, “MasterAID”, “%DBName%”)
            frmMain.GridControl1.Columns(“Database”).CellViewerManager = viewer

            ‘Dim simpleComboBoxEditor As New ComboBoxEditor(sztmpDS, “Database”, “database_id”, “%NAME%”)
            ‘simpleComboBoxEditor.TemplateControl.DropDownSize = New Size(150, 150)
            ‘frmMain.GridControl1.Columns(“Database”).CellEditorManager = simpleComboBoxEditor
            ‘frmMain.GridControl1.Columns(“Database”).CellViewerManager = New ComboBoxViewer(sztmpDS, “Database”, “database_id”, “%Name%”)
    ‘ This also does not work

     

            Dim column2 As New Column(“Tables”, GetType(String))
            frmMain.GridControl1.Columns.Add(column2)

     

            ‘first set columns of grid visible false
            internalDC = New DataColumn
            i = 0

     

     

            Dim MasDetTemplate As New DetailGrid()
            MasDetTemplate.SetDataBinding(sztmpDS, sztmpDS.Tables(1).TableName)
            MasDetTemplate.HeaderRows.Add(New ColumnManagerRow())
            MasDetTemplate.HeaderRows.Add(New InsertionRow())
            MasDetTemplate.Collapsed = True
            ‘      XceedGridContainer.SetGridStyle(MasDetTemplate)

          

            frmMain.GridControl1.Title = “Template”
            MasDetTemplate.Title = “Fields”

            frmMain.GridControl1.DetailGridTemplates.Add(MasDetTemplate)
          
            frmMain.GridControl1.UpdateDetailGrids()

          
            frmMain.GridControl1.ScrollBars = Xceed.Grid.GridScrollBars.Both

            Dim m_spacerRow As SpacerRow

            m_spacerRow = New SpacerRow()
            m_spacerRow.Height = 4

            With frmMain.GridControl1
                .DataRowTemplate.AutoHeightMode = AutoHeightMode.AllContent
                .DataRowTemplate.FitHeightToEditors = True
                .FixedHeaderRows.Add(m_spacerRow)
            End With

     

     

            frmMain.GridControl1.EndInit()

    The code goes as below

     Dim internalDC As DataColumn
            Dim i As Integer
            Dim sztmpDS As DataSet

            Dim szPArentCol, szChildCol, szSubChildCol As String

            sztmpDS = New DataSet
            sztmpDS = getSmartDS()
            If sztmpDS.Tables.Count > 2 Then
                MsgBox(“Datasaet not Retrived, or Error Retriving Records”, MsgBoxStyle.Information, “Error with Dataset”)
                Exit Sub
            Else

            End If
            szPArentCol = “MasterAID”
            szChildCol = “ParentID”

             frmMain.GridControl1.BeginInit()
            Debug.Print(sztmpDS.Tables(0).TableName & ” – ” & sztmpDS.Tables(1).TableName)

            Dim dataRelate As New DataRelation(“MasterDetail”, _
                    sztmpDS.Tables(0).Columns(szPArentCol), _
                    sztmpDS.Tables(1).Columns(szChildCol), True)
            sztmpDS.Relations.Add(dataRelate)

     

            frmMain.GridControl1.SetDataBinding(sztmpDS, sztmpDS.Tables(0).TableName)

            Dim column1 As New Column(“Database”, GetType(String))
            frmMain.GridControl1.Columns.Add(column1)

            Dim viewer As New ComboBoxViewer(sztmpDS, sztmpDS.Tables(0).TableName, “MasterAID”, “%DBName%”)
            frmMain.GridControl1.Columns(“Database”).CellViewerManager = viewer

            ‘Dim simpleComboBoxEditor As New ComboBoxEditor(sztmpDS, “Database”, “database_id”, “%NAME%”)
            ‘simpleComboBoxEditor.TemplateControl.DropDownSize = New Size(150, 150)
            ‘frmMain.GridControl1.Columns(“Database”).CellEditorManager = simpleComboBoxEditor
            ‘frmMain.GridControl1.Columns(“Database”).CellViewerManager = New ComboBoxViewer(sztmpDS, “Database”, “database_id”, “%Name%”)
    ‘ This also does not work

     

            Dim column2 As New Column(“Tables”, GetType(String))
            frmMain.GridControl1.Columns.Add(column2)

     

            ‘first set columns of grid visible false
            internalDC = New DataColumn
            i = 0

     

     

            Dim MasDetTemplate As New DetailGrid()
            MasDetTemplate.SetDataBinding(sztmpDS, sztmpDS.Tables(1).TableName)
            MasDetTemplate.HeaderRows.Add(New ColumnManagerRow())
            MasDetTemplate.HeaderRows.Add(New InsertionRow())
            MasDetTemplate.Collapsed = True
            ‘      XceedGridContainer.SetGridStyle(MasDetTemplate)

          

            frmMain.GridControl1.Title = “Template”
            MasDetTemplate.Title = “Fields”

            frmMain.GridControl1.DetailGridTemplates.Add(MasDetTemplate)
          
            frmMain.GridControl1.UpdateDetailGrids()

          
            frmMain.GridControl1.ScrollBars = Xceed.Grid.GridScrollBars.Both

            Dim m_spacerRow As SpacerRow

            m_spacerRow = New SpacerRow()
            m_spacerRow.Height = 4

            With frmMain.GridControl1
                .DataRowTemplate.AutoHeightMode = AutoHeightMode.AllContent
                .DataRowTemplate.FitHeightToEditors = True
                .FixedHeaderRows.Add(m_spacerRow)
            End With

     

     

            frmMain.GridControl1.EndInit()

     

    Imported from legacy forums. Posted by Credits (had 1766 views)

    User (Old forums)
    Member
    Post count: 23064

    I am able to get the visual master detail grid, but not able to set the relation. For each record of master it shows all rows of detail.

    Combobox is still a problem ?

    Imported from legacy forums. Posted by Credits (had 388 views)

    User (Old forums)
    Member
    Post count: 23064

    I suggest you read the documentation on how to bind the grid, and make sure you understand exactly how it works.

    http://doc.xceedsoft.com/products/XceedGrid/Building_a_bound_hierarchical_master_detail_grid.html

    I already explained to you in another thread how to do it (http://xceed.com/CS/forums/thread/12649.aspx), so it is difficult to add to that.

    As for the WinComboBox, I suggest you create a simple sample application, and set one up in it.  Then when it works, rebuild you grid as you want it, one piece at a time, until you get where you want, making sure everything you add is not breaking anything.  This way you should be able to resolve your issues.

    One more thing that can help you with the WinComboBox is to make the debugger to break on all exceptions (because I suspect there is an exception that is thrown).

    In Visual Studio, go to Debug Menu -> Exceptions -> Common Language Runtime Exception, then select the “Thrown” CheckBox.

    Make sure the “Enable Just My Code” CheckBox is unselected (Tools Menu -> Options -> Debugging -> General).

    This will make sure that no exceptions are swallowed by the grid or the .NET framework, and that the debugger will break in any part of the code, not just yours.

     

    Imported from legacy forums. Posted by André (had 536 views)

    User (Old forums)
    Member
    Post count: 23064

    yes … as correctly said, i did the same earlier and then i worked fine, but the same piece of code this time is again giving error. i couldnt understand how exactly the relation are set. is it that

    1. If Database tables have t he relations defined then , grid takes that automatically

    2. is that the dataset what you retrive needs to be assigned relation between parent and child field

    3. OR the datamember set to the grid along with Dataset plays a trick,

    i have seen past some fourms where it is advised to …

    1. retrive Dataset

    2. Set Relation ship

    3. Set binging to grid … using the datamember as “tablename.relation1.relation2 ……” something like that.

     

    For winbox, what you suggest will try that. Thanks for your reply ….

    Imported from legacy forums. Posted by Credits (had 1217 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.