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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

38135 Dec 6,2005 12:51 PM Dec 6,2005 01:54 PM Windows Forms 1
loading
Tags: GridControl
Gergely Varadi
Asked On December 6, 2005 12:51 PM

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

Administrator [Syncfusion]
Replied On December 6, 2005 01:54 PM

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()

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;