There is IsSelected property on cells and rows, but when I programically select row/cell, there is still one more selected (first row) which was there after grid initialization. I tried to deselect row by this, but with no result
if (radGridView1.CurrentRow != null) radGridView1.CurrentRow.IsSelected = false;
9 Answers, 1 is accepted
0
Hi Daniel,
Thank you for your question.
The confusion comes from the fact that there is a current row and selected rows which are visualized in the same way from the theme. There is always a current row and even if you set its IsSelected property to false it will still looks like selected, though technically it is not.
Please do not hesitate to contact me if you have further questions.
Best wishes,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for your question.
The confusion comes from the fact that there is a current row and selected rows which are visualized in the same way from the theme. There is always a current row and even if you set its IsSelected property to false it will still looks like selected, though technically it is not.
Please do not hesitate to contact me if you have further questions.
Best wishes,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Daniel
Top achievements
Rank 1
answered on 04 Jan 2009, 11:24 AM
Hi Nick, how am I supposed to clear selection then?
0
Happy New Year, Daniel.
There is no way to do this, I am afraid. We are currently working on distinguishing between IsCurrent and IsSelected. I hope that will be able to provide this functionality in the second Service Pack, scheduled to be released this month.
Best wishes,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
There is no way to do this, I am afraid. We are currently working on distinguishing between IsCurrent and IsSelected. I hope that will be able to provide this functionality in the second Service Pack, scheduled to be released this month.
Best wishes,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Daniel
Top achievements
Rank 1
answered on 29 Jan 2009, 07:25 PM
Is there any progress on this matter? I'm trying to do this within multi-column combo box when there is no item selected, but still without results. Thx
Daniel
Daniel
0
Accepted
Hello Daniel,
Thank you for your inquiry. I am happy to give you a positive answer. Since our latest release Q3 2008 SP2 the default theme uses slightly different colors for the selected rows and the current row. Do not hesitate to contact me back if you have more questions.
Regards,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for your inquiry. I am happy to give you a positive answer. Since our latest release Q3 2008 SP2 the default theme uses slightly different colors for the selected rows and the current row. Do not hesitate to contact me back if you have more questions.
Regards,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eric
Top achievements
Rank 1
answered on 02 Mar 2012, 05:28 PM
Ok, fast forward 3 years... I'm still having this problem. Is it really true you still cannot change the selected cell programatically in a way that is clear to the user that the selection has actually changed? I really need a work around. To me this is a critical bug in the grid. All I am trying to do is to allow a user to type and find the next matching text down the selected column. I've been able to do that part if only to be hung up on this problem... old selected cell and row will not clear out (from the user perspective). Here is the function. The search part works great. The new row is highlighted, but I cannot clear the old one. Also, the grid won't scroll to the new row (see comment about the row getting deleted if I call row.EnsureVisible()).
I have a video I can provide to show you the behavior.
Private Sub FindRow(match As String) Dim iCol As Integer Dim iStartRow As Integer If gridView.CurrentCell IsNot Nothing Then iCol = gridView.CurrentCell.ColumnIndex iStartRow = gridView.CurrentCell.RowIndex + 1 If iStartRow = gridView.Rows.Count Then Return 'at end already End If gridView.ClearSelection() gridView.Rows(0).IsCurrent = False gridView.CurrentCell.IsCurrent = False 'anything else I need to do here??? I can't get the selected row to highlight End If For iRow As Integer = iStartRow To gridView.Rows.Count - 1 Dim row As GridViewRowInfo = gridView.Rows(iRow) If row.Cells(iCol).Value IsNot Nothing _ AndAlso row.Cells(iCol).Value.ToString().StartsWith(match) Then gridView.ClearSelection() row.IsCurrent = True row.IsSelected = True row.Cells(iCol).IsSelected = True 'row.EnsureVisible() 'DON'T call this or it eats the row!!! Return End If Next End SubI have a video I can provide to show you the behavior.
0
Hi Eric,
Notice that the code snippet above is tested in Q1 2011 (2012.1.12.215). If the proposed solution does not fit your requirements, could you send us a sample project by opening new support ticket? This will help us to investigate your scenario in depth. Kind regards,
Svett
the Telerik team
You can use the following code snippet to achieve the desired behavior:
Private Sub FindRow(match As String) Dim currentRow As GridViewDataRowInfo = TryCast(Me.radGridView1.CurrentRow, GridViewDataRowInfo) Dim columnName As String = If(Me.radGridView1.CurrentColumn IsNot Nothing, Me.radGridView1.CurrentColumn.Name, Nothing) If String.IsNullOrEmpty(columnName) Then Return End If If currentRow IsNot Nothing AndAlso currentRow.Index = Me.radGridView1.ChildRows.Count - 1 Then Return End If Me.radGridView1.CurrentRow = Nothing For Each row As GridViewRowInfo In Me.radGridView1.ChildRows Dim value As Object = row.Cells(columnName).Value If value IsNot Nothing AndAlso Convert.ToString(value).StartsWith(match) Then Me.radGridView1.CurrentRow = row Exit For End If NextEnd SubNotice that the code snippet above is tested in Q1 2011 (2012.1.12.215). If the proposed solution does not fit your requirements, could you send us a sample project by opening new support ticket? This will help us to investigate your scenario in depth. Kind regards,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Eric
Top achievements
Rank 1
answered on 05 Mar 2012, 08:36 PM
Thank you, this worked! A couple of items...
1. Can you please enter a bug on the fact that the line
row.IsCurrent
... doesn't work?
2. This solution works only until the user resorts the table using the header resorting. Basically, the indexes of the rows are based on the original sort and the visual sorting is apparently stored somewhere else. How can I traverse the visible cells regardless of how the user arrived at it? This would be the same problem with using the row filtering as well I imagine.
Update: I found the problem with item 2... the solution should be modified to search only the child rows. Per http://www.telerik.com/help/winforms/gridview-rows-rows-vs-childrows.html the childRows collection contain the UI visible version of the data where as the .Rows is the original dataSource.
Eric
1. Can you please enter a bug on the fact that the line
row.IsCurrent
... doesn't work?
2. This solution works only until the user resorts the table using the header resorting. Basically, the indexes of the rows are based on the original sort and the visual sorting is apparently stored somewhere else. How can I traverse the visible cells regardless of how the user arrived at it? This would be the same problem with using the row filtering as well I imagine.
Update: I found the problem with item 2... the solution should be modified to search only the child rows. Per http://www.telerik.com/help/winforms/gridview-rows-rows-vs-childrows.html the childRows collection contain the UI visible version of the data where as the .Rows is the original dataSource.
Eric
0
Hello Eric,
Svett
the Telerik team
I am glad to hear that you have managed to resolve item no. 2. I am not able to reproduce the issue of setting the current row by using the IsCurrent property. I modified the FindRow method to use the property and everything works well for me:
Private Sub FindRow(match As String) Dim currentRow As GridViewDataRowInfo = TryCast(Me.radGridView1.CurrentRow, GridViewDataRowInfo) Dim columnName As String = If(Me.radGridView1.CurrentColumn IsNot Nothing, Me.radGridView1.CurrentColumn.Name, Nothing) If String.IsNullOrEmpty(columnName) Then Return End If If currentRow IsNot Nothing AndAlso currentRow.Index = Me.radGridView1.ChildRows.Count - 1 Then Return End If If currentRow IsNot Nothing Then currentRow.IsCurrent = False End If For Each row As GridViewRowInfo In Me.radGridView1.ChildRows Dim value As Object = row.Cells(columnName).Value If value IsNot Nothing AndAlso Convert.ToString(value).StartsWith(match) Then row.IsCurrent = True Exit For End If NextEnd SubCould you open a support ticket and enclose a sample project where the issue occurs? This will allow us to assist you further.
All the best,Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>