We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Selection is broken if ColCount=0 and then ColCount=...

I have to dynamically add/remove columns in a grid, allowing removing all columns and insert different ones. The following problem occurs: 1. Insert a GridControl in a form, and a Label in the GridControl. 2. Set GridControl.ListBoxSelectionMode = MultiExtended 3. After having written the following code, select a row and click on the label. The selection breaks. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.GridControl1.ColCount = 2 End Sub Private Sub Label1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.Click Me.GridControl1.BeginUpdate() Dim cnt As Integer = Me.GridControl1.ColCount + 1 Me.GridControl1.ColCount = 0 Me.GridControl1.ColCount = cnt Me.GridControl1.EndUpdate() End Sub

1 Reply

AD Administrator Syncfusion Team December 6, 2005 06:54 PM UTC

I think you can avoid this problem using this code. Me.GridControl1.BeginUpdate() Dim cnt As Integer = Me.GridControl1.ColCount + 1 Dim ranges As GridRangeInfoList = Me.GridControl1.Selections.GetSelectedRows(True, False) Me.GridControl1.ColCount = 0 Me.GridControl1.ColCount = cnt For Each r As GridRangeInfo In ranges Dim range As GridRangeInfo = r range = GridRangeInfo.Rows(range.Top, range.Bottom) Me.GridControl1.Selections.Add(range) Next Me.GridControl1.EndUpdate()

Loader.
Live Chat Icon For mobile
Up arrow icon