Home Forums WinForms controls Xceed Grid for WinForms Master/Detail/Detail2 — Detail2 Grid Data Repeating

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

    I have a grid Master/ Detail (Master of) / Detail

    I have got everything working with adding/ updating / deleting records to their respective tables, however my last Detail grid shows the same record for all of the First Detail Grids.


    Master — Vendor Number Date Qty
    Detail Vendor Detail id 1
    Detail 2 Vendor Response 1
    Detail Vendor Detail id 2
    Detail 2 Vendor Response 1
    Master Vendor Number 2 Date Qty
    Detail Vendor Detail id 3
    Detail2 Vendor Response 1

    Hopefully that is more easy to understand where Detail 2 is being repeated among all of the detail records under it’s respective Master Record.

    I have detail set up using the same datasource as the master grid and the relation (in this case VendorReturn.VendorReturnVRDetail as datamember

    I have Detail2 set up using the same datasource as the master grid and the relation (in this case VRDetail.VRDetailVendorResponse as datamember

    I am not sure why it’s not correctly separating the grids … can anyone shed some light on this?

    I’ll put the actual code below:

    Grid.BeginInit() ‘ EndInit will be called later
    Dim viewer As New Xceed.Grid.Viewers.ComboBoxViewer(DsVendorReturn1, “Vendors”, “VENDOR”, “%VendorNAME%”)
    Dim editor As New Xceed.Grid.Editors.ComboBoxEditor(DsVendorReturn1, “Vendors”, “VENDOR”, “%VendorNAME%”)
    Grid.SingleClickEdit = True
    Grid.BackColor = Color.FromKnownColor(KnownColor.Control)
    Grid.ScrollBars = GridScrollBars.ForcedBoth
    ‘==GRID SETUP=====================================================================================================
    ‘grid.FixedHeaderRows.Add(New GroupByRow) If TypeOf sender.CurrentCell Is Xceed.Grid.DataCell Then
    Grid.FixedHeaderRows.Add(New ColumnManagerRow)
    ‘Grid.FixedHeaderRows.Add(New InsertionRow)
    ‘ grid.FixedHeaderRows.Add(New ValueRow)
    ‘ grid.FixedHeaderRows.Add(New ValueRow)

    ‘ Add columns to the grid. In the case of our first column,
    ‘ the datatype will be button.
    Grid.Columns.Add(New Column(“Closed”, GetType(Boolean)))
    Grid.Columns.Add(New Column(“Edit”, GetType(System.Windows.Forms.Button)))
    Grid.Columns.Add(New Column(“Credit”, GetType(Integer)))
    Grid.Columns.Add(New Column(“Repaired”, GetType(Integer)))
    Grid.Columns.Add(New Column(“Open”, GetType(Integer)))
    Grid.Columns.Add(New Column(“Closed”, GetType(Boolean)))

    ‘ Assign our custom row to the DataRowTemplate so that the grid will
    ‘ create our custom row rather than the default DataRow

    Grid.DataRowTemplate = New CustomDataRow

    ‘ Set the current column

    Grid.CurrentColumn = Grid.Columns(“Sku”)

    Grid.DataSource = DsVendorReturn1
    Grid.DataMember = “VendorReturn”

    ‘ Add the grid to the form
    Grid.Dock = DockStyle.None

    Grid.Left = 10
    Grid.Top = 50
    Grid.Width = Me.Width – 10
    Grid.Height = 800

    Grid.Columns(“Edit”).Width = 50

    Grid.Columns(“Edit”).VisibleIndex = 0
    Grid.Columns(“RMA”).VisibleIndex = 1
    Grid.Columns(“Qty”).VisibleIndex = 3
    Grid.Columns(“Credit”).VisibleIndex = 4
    Grid.Columns(“Repaired”).VisibleIndex = 5
    Grid.Columns(“Open”).VisibleIndex = 6
    Grid.Columns(“DateSent”).VisibleIndex = 7
    Grid.Columns(“VendorNum”).VisibleIndex = 2

    Grid.Columns(“Closed”).VisibleIndex = 8

    ‘Set up Combo box for VendorName
    Grid.Columns(“VendorNum”).CellEditorManager = editor
    Grid.Columns(“VendorNum”).CellViewerManager = viewer

    Grid.Columns(“DateOriginated”).Visible = False
    Grid.Columns(“ID”).Visible = False
    Grid.Columns(“VendorNAME”).Visible = False

    Dim col As Column
    For Each col In Grid.Columns
    col.HorizontalAlignment = HorizontalAlignment.Center
    col.VerticalAlignment = VerticalAlignment.Center

    ‘ This is the detail grid that will contain the VRDetail Lines
    Dim detail As New DetailGrid

    detail.DataSource = DsVendorReturn1
    detail.DataMember = “VendorReturn.VendorReturnVRDetail”
    detail.HeaderRows.Add(New ColumnManagerRow)
    detail.HeaderRows.Add(New InsertionRow)
    detail.HeaderRows(1).BackColor = Color.Yellow

    detail.BackColor = Color.White
    detail.Columns.Add(New Column(“EditLine”, GetType(System.Windows.Forms.Button)))
    detail.Columns(“EditLine”).Width = 50

    detail.DataRowTemplate = New CustomDataRow

    detail.Columns(“Comments”).Width = 300
    detail.Columns(“ID”).Visible = False
    detail.Columns(“VendorReturn_ID”).Visible = False

    ‘This is the detail grid that will contain the Vendor Response Lines for each VRDetail LIne
    Dim detail2 As New DetailGrid
    detail2.DataSource = DsVendorReturn1
    detail2.DataMember = “VRDetail.VRDetailVendorResponse”
    detail2.HeaderRows.Add(New ColumnManagerRow)
    detail2.HeaderRows.Add(New InsertionRow)
    detail2.BackColor = Color.Wheat
    detail2.Columns.Add(New Column(“EditResponse”, GetType(System.Windows.Forms.Button)))
    detail2.Columns(“EditResponse”).Width = 50
    detail2.DataRowTemplate = New CustomDataRow



    ‘ Because we called BeginInit at the beginning of the process

    ‘ we must call EndInit otherwise none of our modifications

    ‘ will be applied to the grid.


    Imported from legacy forums. Posted by Greg (had 3481 views)

    User (Old forums)
    Post count: 23064

    I figured out that if I set the datasource to nothing for Detail1 and Detail2 and change the datamember to VendorReturnVRDetail and VRDetailVendorResponse respectively, then the grids operate as they should.

    Now the problem I get is I can’t set column widths or visibility for the columns that should be inserted from the datasource (bound columns).

    At this line of code: detail.columns(“Comments”).width = 300
    The error that occurs is: Object reference not set to an instnace of an object

    Not sure how I would do that.

    Imported from legacy forums. Posted by Greg (had 438 views)

    User (Old forums)
    Post count: 23064

    The thing I can’t figure out is when I add the unbound column (Edit button) called EditLine it shows me that there is only one column in detail.columns.count before and after the EndInit line.

    When I run the app, the detail grid has all of the columns that were in the dataset as well as the unbound column.

    How can I access those bound columns?

    Imported from legacy forums. Posted by Greg (had 495 views)

    User (Old forums)
    Post count: 23064

    Figured it out finally.

    Here is what I had to do.

    In the Onclick override function for the cell that was created as a button (in my case “Edit”) I placed the following code in that click event

    Ctype(me.parentrow, xceed.grid.datarow).detailgrids(0).columns(“Comments”).width = 300

    All is better now.

    Imported from legacy forums. Posted by Greg (had 4162 views)

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