Home Forums WinForms controls Xceed Grid for WinForms Horizontal scroll is moving to right Reply To: Horizontal scroll is moving to right

User (Old forums)
Member
Post count: 23064

    Hi,

  In my application I need to use xceed grid using master-child relation and there  should be a checkbox in evevery datarow (master grid and child grid or detailgrid) in fist column.

  And one more restriction is user  should be able to check only one row (if user checks one checkbox then

  other checkbox of each datarow (master and detailgrid) should be unchecked).

 

  To implement this I wrote below the code.  But on binding the items to my xceed grid horizontal scroll is

  moving to the right side slightly and one more is when I check checkbox taking some time to select(check).

 

  Please suggest me on this… Thanks in advance.

 

    Private Sub bindDatatoXceedGrid(ByVal ds As DataSet)

   xgcDirect.DataRows.Clear()

   xgcDirect.Columns.Clear()

   xgcDirect.GroupTemplates.Clear()

   xgcDirect.BeginInit()

   xgcDirect.SingleClickEdit = True

    xgcDirect.FixedColumnSplitter.Visible = False

    xgcDirect.DataRowTemplate.CanBeSelected = False

    xgcDirect.DataRowTemplate.FitHeightToEditors = True

    xgcDirect.SynchronizeDetailGrids = True

    Dim columnDescription As New Column(“Selected”, GetType(Boolean))

    xgcDirect.Columns.Add(columnDescription)

    Dim simpleCheckBox As New CheckBoxEditor

    xgcDirect.Columns(“Selected”).CellEditorManager = simpleCheckBox

    AddHandler xgcDirect.AddingDataRow, AddressOf Me.grid_AddingDataRow

   xgcDirect.SetDataBinding(ds, “Master”)

   SetGridStyle(xgcDirect)

   vistastyle()

   xgcDirect.Title = “Master 1572”

   xgcDirect.DetailGridTemplates.Clear()

   If FrmDirect_ChkShwMasterSub1572.Checked And ds.Tables.Contains(“MasterSub”) Then

     Dim data_relationPISub As New DataRelation(“PISub”,  ds.Tables(“Master”).Columns(“Form ID”), ds.Tables(“MasterSub”).Columns(“Form ID”))

     If Not ds.Relations.Contains(“PISub”) Then

       ds.Relations.Add(data_relationPISub)

     End If

     Dim detailGridTemplateInv As New DetailGrid()

     Dim detailcolumnDescription As New Column(“Selected”, GetType(Boolean))

     detailGridTemplateInv.Columns.Add(detailcolumnDescription)

     Dim detailsimpleCheckBox As New CheckBoxEditor

     detailGridTemplateInv.Columns(“Selected”).CellEditorManager = detailsimpleCheckBox

     AddHandler detailGridTemplateInv.AddingDataRow, AddressOf Me.grid_AddingDataRow

     detailGridTemplateInv.SetDataBinding(ds, “Master.PISub”)

     detailGridTemplateInv.Collapsed = True

     detailGridTemplateInv.HeaderRows.Add(New ColumnManagerRow())

     xgcDirect.DetailGridTemplates.Add(detailGridTemplateInv)

     For i As Integer = 1 To detailGridTemplateInv.Columns.Count – 1

        detailGridTemplateInv.Columns(i).ReadOnly = True

     Next

   End If

  End Sub

 

  Private Sub grid_AddingDataRow(ByVal sender As Object, ByVal e As Xceed.Grid.AddingDataRowEventArgs)

    e.DataRow.Cells(“Selected”).Value = False

    Dim tmpObj As Object

    tmpObj = e.DataRow.Cells(“Selected”).CellEditorControl

    AddHandler   e.DataRow.Cells(“Selected”).CellEditorManager.ActivatingControl, AddressOf CellEditorManager_ActivatingControl

    AddHandler e.DataRow.Cells(“Selected”).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_DeactivatingControl

    End Sub

 

  Private Sub CellEditorManager_ActivatingControl(ByVal sender As Object, ByVal e As CellEditorEventArgs)

   AddHandler DirectCast(e.Control, Xceed.Editors.WinCheckBox).CheckedChanged, AddressOf selected_checked

  End Sub

 

  Private Sub CellEditorManager_DeactivatingControl(ByVal sender As Object, ByVal e As CellEditorEventArgs)

   RemoveHandler DirectCast(e.Control, Xceed.Editors.WinCheckBox).CheckedChanged, AddressOf selected_checked

    End Sub

 

  Private Sub selected_checked(ByVal sender As Object, ByVal e As System.EventArgs)

  If bSelectChanged Then

  For i As Integer = 0 To xgcDirect.DataRows.Count – 1

    bSelectChanged = False

    xgcDirect.DataRows(i).Cells(“Selected”).Value = False

    For j As Integer = 0 To xgcDirect.DataRows(i).DetailGrids.Count – 1

   For k As Integer = 0 To xgcDirect.DataRows(i).DetailGrids(j).DataRows.Count – 1

 xgcDirect.DataRows(i).DetailGrids(j).DataRows(k).Cells(“Selected”).Value = False

      Next

    Next

  Next

  bSelectChanged = True

  End If

    End Sub

 

 

Imported from legacy forums. Posted by pravi (had 594 views)