This is a migrated thread and some comments may be shown as answers.
Change visual element when grid has focus
3 Answers 28 Views
This is a migrated thread and some comments may be shown as answers.
Victoria
Top achievements
Rank 1
Victoria asked on 17 Apr 2013, 12:56 PM

Hello, 

I have a form with 4 grid controls on it, using office2010black theme. Each one is based on the one before it in a hierarchy mode but for work flow reasons I am not wanting to use a single grid. 

It's working beautifully so far but the only complaint is the user doesn't know which grid has the focus before using arrows or enter for navigation. If I could change the row selection colour or even just stick a coloured border round the grid that has focus that would be great. 

I tried changing the grid border in the grid's enter event but nothing changed I'm assuming as all the visual style examples I found in the forums seem to fire off the grid formatting event which by the time my user is clicking round the grids is long over. 

Is there something I can change after the form is loaded and the grids are filled with data to indicate which one has focus that will fire off when the user clicks on or tabs into a grid?

3 Answers, 1 is accepted

Sort by
0
Accepted
Paul
Telerik team
answered on 19 Apr 2013, 01:14 PM
Hello Victoria,

Thank you for writing.

What you can do is to set up some Padding for your grids, the number is in pixels and you can set the most suitable for you size. After that you can listen for the GotFocus event and change the BackColor property of your grids. Follows a sample which will give you a good idea of how to achieve all of the above. I have set some sample colors but you can change them in the most suitable for you way:
public partial class Form1 : RadForm
{
    public Form1()
    {
        InitializeComponent();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        foreach (Control ctrl in this.Controls)
        {
            if (ctrl is RadGridView)
            {
                ctrl.Padding = new System.Windows.Forms.Padding(2);
                ctrl.GotFocus += radGridView_GotFocus;
            }
 
        }
    }
 
    void radGridView_GotFocus(object sender, EventArgs e)
    {
        foreach (RadGridView grid in this.Controls)
        {
            if (grid == sender)
            {
                grid.BackColor = Color.Red;
            }
            else
            {
                grid.BackColor = Color.DarkGray;
            }
        }
    }
}

I hope this helps. Please do not hesitate to contact us for any further questions.

Kind regards,
Nikolay Aleksiev
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Victoria
Top achievements
Rank 1
answered on 24 Apr 2013, 03:13 PM
Thank you very much, with a little tweaking (I have all my grids in groupboxes) it is working nicely. Apologies for the delay in replying, I've been home with a sick kid.

Victoria
0
Paul
Telerik team
answered on 29 Apr 2013, 11:42 AM
Hello Victoria,

I am glad the solution worked. No worries about the delay. Hope your kid got well.

Please do not hesitate to contact us, should you need any further assistance.

Regards,
Nikolay Aleksiev
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Asked by
Victoria
Top achievements
Rank 1
Answers by
Paul
Telerik team
Victoria
Top achievements
Rank 1
Share this question
or