DropDownButton
RadDropDownButton provides a menu-like interface open from a button.
![buttons-dropdownbutton-overview 001](http://www.telerik.com/help/winforms/media/buttons-dropdownbutton-overview001.png)
RadDropDownButton의 각 항목을 클릭 할 때 작업을 실행하도록 설정할 수있다. 또한 아이템을 사용하면 하위 항목의 요구에 맞는 모든 계층을 만들 수 있고 다른 항목을 포함 할 수 있습니다.
RadDropDownButton는 RadSplitbutton 과 시각적으로 차이가 없지만, 프로그램상 차이가 있습니다. RadSplitbutton 의해 위 DefaultItem 속성은 해당 Click 이벤트 버튼을 클릭 할 때 트리거 될 품목입니다. 당신이 선택 메뉴에서 만들 때와 마찬가지로 클릭하면 무언가를 버튼하려면 대신 RadDropDownButton의 RadSplitbutton 의해 사용해야합니다.
The heart of RadDropDownButton is the Items collection. This collection defines the menu items that appear when the RadDropDownButton is clicked. To get started, drag a RadDropDownButton on the surface of your form from the Toolbox. There are two ways to add items to your new button.
Adding Items at Design Time
To add menu items at Design Time, click on the Items property(the ellipsis button) to launch the RadElement Collection Editor. Click the arrow next to the Add button to add items to the menu. You can add a variety of items to the collection.
![buttons-dropdownbutton-working-with-raddropdownbutton-items 001](http://www.telerik.com/help/winforms/media/buttons-dropdownbutton-working-with-raddropdownbutton-items001.png)
Once you have added a RadMenuItem to the collection, it will appear in the list on the left side of the dialog. Click the RadMenuItem to edit its properties in the corresponding property grid on the right of the dialog.
![buttons-dropdownbutton-working-with-raddropdownbutton-items 002](http://www.telerik.com/help/winforms/media/buttons-dropdownbutton-working-with-raddropdownbutton-items002.png)
In the property grid you will find many of the standard control properties, including Text, to control the display text of the item and ToolTipText that displays when the mouse hovers over an item. Each RadMenuItem you add also contains an Items collection of its own, allowing you to create menu hierarchies in the RadDropDownButton. You can also do the following with each item:
- Associate an image to an item using the Image property or associate a standard ImageList component to the RadDropDownButton and use the ImageIndex or ImageKey properties for the item.
- PopupDirection determines the direction in which the sub items of a RadMenuItem will be displayed and can be Left, Right, Up or Down.
- To display sub items in two columns set HasTwoColumns to true and add items to the RightColumnItems collection.
- Use CheckOnClick to toggle a check mark next to a RadMenuItem. This property is appropriate to use when the item doesn't contain sub items.
Adding Items at Run Time in Code
You can also add RadDropDownButton items in code at Run Time. The following example code illustrates how to programmatically add a RadMenuItem to your button.
[C#] Adding RadDropDownButton items
void Form1_Load(object sender, EventArgs e) { RadMenuItem myRadMenuItem = new RadMenuItem(); myRadMenuItem.Text = "My New Item"; radDropDownButton1.Items.Add(myRadMenuItem); myRadMenuItem.Click += new EventHandler(myRadMenuItem_Click); } void myRadMenuItem_Click(object sender, EventArgs e) { MessageBox.Show((sender as Telerik.WinControls.UI.RadMenuItem).Text + " was clicked."); }
[C#] Adding sub items
using Telerik.WinControls.UI; namespace RadDropDownButtonDemo { public partial class Form1 : Form { private void Form1_Load(object sender, EventArgs e) { RadMenuItem mainItem = radDropDownButton1.Items[0] as RadMenuItem; RadMenuItem mySubMenuItem = new RadMenuItem(); mySubMenuItem.Text = "Submenu Item"; mySubMenuItem.Click += new EventHandler(mySubMenuItem_Click); mainItem.Items.Add(mySubMenuItem); } void mySubMenuItem_Click(object sender, EventArgs e) { MessageBox.Show((sender as RadMenuItem).Text + " was clicked."); } } }
[VB.NET] Adding RadDropDownButton items
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim myRadMenuItem As New RadMenuItem() myRadMenuItem.Text = "My New Item" radDropDownButton1.Items.Add(myRadMenuItem) AddHandler myRadMenuItem.Click, AddressOf myRadMenuItem_Click End Sub Sub myRadMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show((TryCast(sender, RadMenuItem)).Text + " was clicked.") End SubSimilarly, you can create item hierarchies in code by adding new RadMenuItem objects to the Items collection of your existing RadMenuItem.
[VB.NET] Adding sub items
Imports System.Windows.Forms Imports Telerik.WinControls.UI Namespace RadDropDownButtonDemo Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Dim mainItem As RadMenuItem = TryCast(radDropDownButton1.Items(0), RadMenuItem) Dim mySubMenuItem As New RadMenuItem() mySubMenuItem.Text = "Submenu Item" AddHandler mySubMenuItem.Click, AddressOf mySubMenuItem_Click mainItem.Items.Add(mySubMenuItem) End Sub Sub mySubMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show((TryCast(sender, RadMenuItem)).Text + " was clicked.") End Sub End Class End Namespace
Using Click Events
To handle the Click event of individual RadMenuItems on the drop down menu at Design Time, locate the RadMenuItem in the drop down list in the Properties window of the Windows Form designer. Click the events button, then double-click the Click event to generate an event handler. Then fill in your event-handling code.
'Programming > RadControl for WINFORMS' 카테고리의 다른 글
RadButton (0) | 2013.04.22 |
---|