• Programming by 白影를 방문하신 여러분을 환영합니다 :)

DropDownButton

Programming/RadControl for WINFORMS 천재작곡가 2013. 4. 22. 19:15

RadDropDownButton provides a menu-like interface open from a button.

buttons-dropdownbutton-overview 001

RadDropDownButton 각 항목을 클릭 할 때 작업 실행하도록 설정할 수있다. 또한 아이템 사용하면 하위 항목 요구에 맞는 모든 계층을 만들 수 있고 다른 항목을 포함 할 수 있습니다.

RadDropDownButton 사용하려면 도구 상자에서 폼 디자이너 표면에 RadDropDownButton 드래그합니다. 표준 단추처럼 Text 속성을 설정하여 표시되는 텍스트 제어 할 수 있습니다. 표준 단추와 달리 RadDropDownButton 클릭 할 아이템을 드롭 다운 표시됩니다. 그래서 버튼 Click 이벤트를 처리하는 것은 적절하지 않습니다. 대신 각 항목 이벤트를 직접 조작. RadDropDownButton의 항목을 만들고 사용하는 방법을 학습하려면 Telerik 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.

Collapse imageAdding 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

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

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.

Collapse imageAdding 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

RadButton

Programming/RadControl for WINFORMS 천재작곡가 2013. 4. 22. 19:01

buttons-button-overview 001

  • RadButton은 기본 Winforms 버튼을 대체하며, 테마를 지원합니다.
  • RadButton을 폼에 드래그하여 추가합니다.

코딩을 이용하여 버튼을 추가하는경우는 아래의 소스를 참조하세요

[C#]에서 RadButton 추가

RadButton myNewRadButton = new RadButton();
myNewRadButton.Text = "My New RadButton";
myNewRadButton.Width = 150;
myNewRadButton.Height = 50;
this.Controls.Add(myNewRadButton);
[VB.NET]에서 RadButton 추가
Dim myNewRadButton As New RadButton()
myNewRadButton.Text = "My New RadButton"
myNewRadButton.Width = 150
myNewRadButton.Height = 50
Me.Controls.Add(myNewRadButton)

 

 

또한 버튼안에 들어가는 텍스트는 HTML 태그를 이용할수 있으며, 지원하는 태그는 다음과 같습니다.

<font> N/A

폰트 설정

<color> N/A 글자 색.
<size> N/A 글자크기.
<b> </b> 굵게.
<i> </i> 기울임꼴.
<u> </u>

텍스트 밑줄

<br> N/A

줄바꿈.

 

다음은 예제 코드입니다.

[C#]

this.radButton1.Text = "This is RadLabel 
Arial, Bold
Times, Italic Underline
Size = 9
Sample Text";
[VB.NET]

Me.radButton1.Text = "This is RadLabel 
Arial, Bold
Times, Italic Underline
Size = 9
Sample Text"

buttons-button-html-like-text-formatting 001

'Programming > RadControl for WINFORMS' 카테고리의 다른 글

DropDownButton  (0) 2013.04.22
1