Hi Telerik,
I use dropdownbutton and I want that his text takes the value if the item choosed. For example, I have a drop down button with those items(All,Month...). So As a result, button.text="All" or the other item name.Is it possible?
I use dropdownbutton and I want that his text takes the value if the item choosed. For example, I have a drop down button with those items(All,Month...). So As a result, button.text="All" or the other item name.Is it possible?
4 Answers, 1 is accepted
0
Hi Najoua,
If the drop-down list is flat (with no hierarchy) the easiest way to do this is to use RadComboBox. If you want to have hierarchical menus in the drop-down you will have to use RadDropDownButton or RadSplitButton. In both cases you will need to write some code.
Here is given example for RadDropDownButton.
First subscribe for Load and FormClose events of the Form and fill them like this:
Then add these private methods to the body of your Form class:
Hope this was helpful.
Sincerely yours,
Angel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
If the drop-down list is flat (with no hierarchy) the easiest way to do this is to use RadComboBox. If you want to have hierarchical menus in the drop-down you will have to use RadDropDownButton or RadSplitButton. In both cases you will need to write some code.
Here is given example for RadDropDownButton.
First subscribe for Load and FormClose events of the Form and fill them like this:
private void Form1_Load(object sender, EventArgs e) |
{ |
RadDropDownButtonElement buttonElement = (RadDropDownButtonElement)this.radDropDownButton1.RootElement.Children[0]; |
SubscribeMenuItems(buttonElement.DropDownMenu.Items); |
} |
private void Form1_FormClosed(object sender, FormClosedEventArgs e) |
{ |
RadDropDownButtonElement buttonElement = (RadDropDownButtonElement)this.radDropDownButton1.RootElement.Children[0]; |
UnsubscribeMenuItems(buttonElement.DropDownMenu.Items); |
} |
Then add these private methods to the body of your Form class:
private void SubscribeMenuItems(RadItemCollection menuItems) |
{ |
for (int i = 0; i < menuItems.Count; i++) |
{ |
RadMenuItem subMenuItem = menuItems[i] as RadMenuItem; |
if (subMenuItem != null) |
{ |
if (subMenuItem.Items.Count == 0) |
subMenuItem.Click += new EventHandler(DropDownMenuItem_Click); |
else |
SubscribeMenuItems(subMenuItem.Items); |
} |
} |
} |
private void UnsubscribeMenuItems(RadItemCollection menuItems) |
{ |
for (int i = 0; i < menuItems.Count; i++) |
{ |
RadMenuItem subMenuItem = menuItems[i] as RadMenuItem; |
if (subMenuItem != null) |
{ |
if (subMenuItem.Items.Count == 0) |
subMenuItem.Click -= new EventHandler(DropDownMenuItem_Click); |
else |
UnsubscribeMenuItems(subMenuItem.Items); |
} |
} |
} |
private void DropDownMenuItem_Click(object sender, EventArgs e) |
{ |
RadMenuItem clickedMenuItem = (RadMenuItem)sender; |
this.radDropDownButton1.Text = clickedMenuItem.Text; |
} |
Hope this was helpful.
Sincerely yours,
Angel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Najoua
Top achievements
Rank 1
answered on 15 Aug 2007, 06:55 AM
Hi telerik,
Thanks for your replay but I need one more support, if it is possible.
the dropdown button I use is included in a usercontrol and not a form.So how can I define the formclosed event for usercontrol?
Thanks for your replay but I need one more support, if it is possible.
the dropdown button I use is included in a usercontrol and not a form.So how can I define the formclosed event for usercontrol?
0
Najoua, this question is outside the scope of our products and we are not sure we are in the position to handle such questions. May we suggest reviewing Google and/or to trying the forums on http://windowsclient.net/? We think you will get better and more complete replies there. Thank you for your understanding.
Best wishes,
Rob
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Best wishes,
Rob
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Najoua
Top achievements
Rank 1
answered on 15 Aug 2007, 07:31 AM
thanks for all.I have already find the solution to my question.
Excuse me!
Excuse me!