Search code examples
telerikradgridview

Telerik RadGrid : Raise an event in Form when the Form Window is Maximized


I have a RadgridView along with a button in a Form Window.When the button is clicked , it shows some hidden rows in RadGridView.

I want the hidden rows to be showed when the Form window is maximized. I am trying something like this in Form_Activated method:

If Me.WindowState=2 Then
    button1.PerformClick()

upon Debugging, I can see that the method that handles click event executes but nothing is being done in the Form Window i.e the columns are not showing up. Am I missing something? What should I do?


Solution

  • You will need to handle the WindowStateChanged event, see https://docs.telerik.com/devtools/wpf/controls/radwindow/features/states

    In that event you will need to check the WindowState of your Window object. Since you have not specified which class is the one where you handle the event, the Me might be referring to something different from your window. For WindowStateChanged the sender contains the RadWindow. You will need to debug and figure out which member of the sender is the RadWindow. It may be the sender itself. You will need to refer WindowState through the sender.

    Also, I recommend that you could avoid triggering clicks in order to change UI properties. You could just have a function which handles every change necessary when the window is maximalized and call that instead of doing a click.

    As explained in the comment section, this logic needs to be handled in the Resize event.