This is a migrated thread and some comments may be shown as answers.

Get a reference to Conditional Formatting form

1 Answer 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Renu
Top achievements
Rank 1
Renu asked on 06 Feb 2009, 09:03 AM
Hi,

In a  grid view clicking on the menu item ConditionFormatting opens a Conditional Formatting form.
Requirement is to set it's topMost property to True and set focus on it(if opened) at the time of refreshing the grid view. But I am not getting any refrence to this form so that i can call form.TopMost  = true and form.Focus() and also we can open several ConditionalFormatting form at the same time. So i want to focus the current form on which user was working recently.
i tried it this way  at the time of refreshing the GridView but it sets focus to first Conditional Formatting form.


bool setFocusTogridView = true;

foreach (Form form in Application.OpenForms)

{

if (form.GetType() == typeof(ConditionalFormattingForm))

{

form.TopMost = true;

form.Focus();

setFocusTogridView = false;

break;

}

}

if(setFocusTogridView)

this.gridView.Focus();

Please let me know if there is some solution for this problem.

I am using Telrik version 8.2.0.0.

Regards,
Renu

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 09 Feb 2009, 10:28 AM
Hello Renu,

Thank you for this question.

You cannot access the conditional formatting form in RadGridView. Nevertheless, you can change the context menu item that shows this form and replace it with your own. Consider the code below:

void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) 
{           
    for (int i = 0; i<e.ContextMenu.Items.Count; i++) 
    { 
        RadMenuItemBase item = (RadMenuItemBase)e.ContextMenu.Items[i]; 
        if (item.Text == "Conditional Formatting"
        { 
            e.ContextMenu.Items.Remove(item); 
            RadMenuItem newItem = new RadMenuItem("Conditional Formatting"); 
            newItem.Click += new EventHandler(newItem_Click); 
            e.ContextMenu.Items.Insert(4, newItem); 
            break
        } 
    } 
 
void newItem_Click(object sender, EventArgs e) 
    ConditionalFormattingForm cf = new ConditionalFormattingForm(this.radGridView1.MasterGridViewTemplate, null); 
    cf.TopMost = true
    cf.Show(); 
    cf.Focus(); 

I hope this helps. Feel free to write us back if you need further assistance.

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Renu
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or