How to disable highlight for current row during multiple selection ?

5 posts, 1 answers
  1. Kun
    Kun avatar
    44 posts
    Member since:
    Aug 2018

    Posted 11 Jan 2019 Link to this post

    Hello,

    I use multiselect in my gridview. I've found a strange behavior when I deselect a row among several selected rows.

    For example,

    Step 1, I've selected 4 rows by using Shift+left click. Here is the row stats.

    Row Index | IsSelected | highlighted | isCurrent

        0            |     yes         |      yes       |      no

        1            |     yes         |      yes       |      no

        2            |     yes         |      yes       |      no

        3            |     yes         |      yes       |     yes

    Step 2, I've deselected third row by using Ctrl+left click. In terms of display, nothing changes.
    Row Index | IsSelected | highlighted | isCurrent
        0            |      yes       |        yes     |        no
        1            |     yes        |        yes     |        no
        2            |     no          |        yes     |       yes
        3            |     yes        |        yes      |       no

    Step 3, I've deselected second row by using Ctrl+left click. In terms of display, 3 rows are highlighted, but actually 2 rows are selected.
    Row Index | IsSelected | highlighted | isCurrent
        0            |     yes        |       yes       |       no
        1            |     no          |      yes        |      yes
        2            |     no          |       no        |      no
        3            |     yes         |      yes       |       no

    I understand that current row and selected row are both highlighted. It's comprehensible to developer. But this behavior is not such friendly to software user.

    I tried to disable highlight to current row by using row formatting. No luck.

    To be more clear, I hope that only selected row can be highlighted.

    Please help me. Thank you.

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3759 posts

    Posted 15 Jan 2019 Link to this post

    Hello, Kun,        

    The described behavior sounds correct. Indeed, by design, the selected, current and hovered rows have a specific style applied. The RowFormatting event is an appropriate place the customize the default design and apply the colors you want only for the selected rows. You can find below a sample code snippet how to highlight the rows: 

    private void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)
    {
        if (e.RowElement.RowInfo.IsSelected)
        {
            e.RowElement.DrawFill = true;
            e.RowElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
            e.RowElement.BackColor = Color.Orange;
            e.RowElement.DrawBorder = true;
            e.RowElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
            e.RowElement.BorderColor = Color.Black;
        }
        else
        {
            e.RowElement.DrawFill = false;
            e.RowElement.DrawBorder = false;
        }
    }

    Note that this is just a sample approach and it may not cover all possible cases. In addition, if you want to customize the current cell, feel free to handle the CellFormatting event and adjust the style of the cell according to your custom requirements: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Kun
    Kun avatar
    44 posts
    Member since:
    Aug 2018

    Posted 15 Jan 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you for your reply, Dess,

    Is it possible to define current row/cell style in theme style builder ? Because I use the theme style build to make a personal theme for my software.

    I've tried to figure out by myself. I'm inspired by this following post. 

    https://www.telerik.com/forums/deselect-the-current-row

    But if I did this, all selected rows are deselected. Could you explain the reason and what is the relationship between current row and selected rows ?

    Thank you by advance.

    Private Sub myGridView_SelectionChanged(sender As Object, e As EventArgs) Handles myGridView.SelectionChanged
         If myGridView.CurrentRow IsNot Nothing AndAlso myGridView.CurrentRow.IsSelected = False Then           
             myGridView.CurrentRow.IsCurrent = False
             myGridView.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.StateChanged)
         End If
    End Sub
  4. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3759 posts

    Posted 17 Jan 2019 Link to this post

    Hello, Kun,        

    Note that you may have none, one or more rows selected. However, you may have only one row current which is marked by the arrow indicator in the row header column. Further information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/selected-rows-and-current-row

    As to the questions about Visual Style Builder, of course, you can customize the style of RadGridView in Visual Style Builder.  Note that its is important to select the element you want to customize of the left side, select the element state for which you want to apply a style and modify the existing repository items or create a new one. The following screenshot navigates you to the fill repository  of the current state of a cell. Thus, you can either change the color or deselect the applied one in order to disable the current row indication with a color:



    You can read more details about using the Visual Style Builder here:

    1.     Loading predefined themes
    2.     
    Working with Repository Items
    3.     
    Saving and Loading Theme Files
    4.     
    Loading Themes from an External File
    5.     
    Loading Themes from a Resource
    6.     
    Applying Theme to a Control
    7.     
    http://tv.telerik.com/watch/winforms/visualstylebuilder/whats-new-visual-style-builder-q1-2010

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Kun
    Kun avatar
    44 posts
    Member since:
    Aug 2018

    Posted 17 Jan 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you, Dess. Your answer helps me a lot.
Back to Top