I am trying to force my grid to only allow the user to select a single row at a time. Which seems fairly straightforward, but I can't seem to find the right cocktail of properties to completely accomplish this.
I'm using Infragistics v3 2008 and I have the following code happening with a clean UltraGrid straight out of the toolbox.
The problem is when I click on a row, hold down the mouse button and drag it upwards or down. I now have two rows selected, but I only want one.
How can I force this grid to only allow a single selected row on screen?
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim odt As New DataTable("Table")
odt.Columns.Add(New DataColumn("Col1", GetType(String)))
odt.Columns.Add(New DataColumn("Col2", GetType(String)))
odt.Columns.Add(New DataColumn("Col3", GetType(String)))
odt.Rows.Add("Happy", "Joy", "Joy")
ug.DataSource = odt
End Sub
Private Sub ug_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ug.InitializeLayout
ug.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
ug.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single
End Class
And that would be it, thanks very much guys.
FAQ:How do I turn off the ActiveRowAppearance so that the active row in the grid does not appear selected.
Hello, From the screenshot I can tell that you have only one selected row when you release the mouse. The other row appear as active. Is seems you have similar appearance set for active and selected rows so that’s way you see the both rows appearing in the same way. But actually the one is selected(one you released the mouse) and the other (the firs selected row) is selected.I have attached a sample where I don’t use the same appearance for selected and active rows and you will be able to see the difference. I hope this information is helpful.
Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.
I'm not sure how to check if there is some other property that may override the SelectTypeRow, but I am not doing anything other than what is in the code I provided anyway. Below is a screenshot.
Can you try copy/pasting this code into a form and running it? When the form is running, click and hold the top row, then drag your mouse a few rows down and release. This will give you two selected rows on the screen.
I'm using Vista Enterprise, Studio 2008, VB, .NET 3.5 SP1 if that matters.
If there is no way to make the UltraGrid do this I'll have to go with something else, but I would prefer not to.
Hello,I am not reproducing the same behavior, I set the same sequence of properties and this is working fine form me. These properties should be enough to get the behavior you want. Check if there is some other property that may override the SelectTypeRow. Also check that you don’t mess the Selected rows and Active rows. You can verify this by getting the selected rows counter.I hope his helps.Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.