![]() ![]() Run this form to see the original position of the Button control with respect to the form. You can set the Anchor property values of a control from the Properties window −įor example, let us add a Button control on a form and set its anchor property to Bottom, Right. When you anchor a control to a form, the control maintains its distance from the edges of the form and its anchored position, when the form is resized. The Anchor property gets or sets the edges of the container to which a control is bound and determines how a control is resized with its parent. The Anchor property of the Control class allows you to set values of this property. Anchoring and Docking Controls in a FormĪnchoring allows you to set an anchor position for a control to the edges of its container control, for example, the form. RichTextBox1.SelectedText = iData.GetData(DataFormats.Text)Įnter some text and check how the buttons work. If (iData.GetDataPresent(DataFormats.Text)) Then Private Sub Button3_Click(sender As Object, e As EventArgs) _ Private Sub Button2_Click(sender As Object, e As EventArgs) _ Private Sub Button1_Click(sender As Object, e As EventArgs) _Ĭlipboard.SetDataObject(RichTextBox1.SelectedText) Private Sub Form1_Load(sender As Object, e As EventArgs) _ Take the following steps −Īdd a rich text box control and three button controls on the form.Ĭhange the text property of the buttons to Cut, Copy and Paste, respectively.ĭouble click on the buttons to add the following code in the code editor − Retrieves text data from the Clipboard in the format indicated by the specified TextDataFormat value.Ĭlears the Clipboard and then adds data in the specified format.Ĭlears the Clipboard and then adds text data in the Text or UnicodeText format, depending on the operating system.įollowing is an example, which shows how we cut, copy and paste data using methods of the Clipboard class. Retrieves text data from the Clipboard in the Text or UnicodeText format, depending on the operating system. Retrieves the data that is currently on the system Clipboard. Retrieves data from the Clipboard in the specified format. Indicates whether there is data on the Clipboard in the Text or UnicodeText format, depending on the operating system. Indicates whether there is data on the Clipboard that is in the Bitmap format or can be converted to that format. Indicates whether there is data on the Clipboard that is in the specified format or can be converted to that format. It has the following commonly used methods − Sr.No. The ClipBoard class provides methods to place data on and retrieve data from the system Clipboard. The methods exposed by the ClipBoard class are used for adding the cut, copy and paste functionalities in an application. ![]() The ToolStripMenuItem control replaces and adds functionality to the MenuItem control of previous versions.Īdding the Cut, Copy and Paste Functionalities in a Form It represents a selectable option displayed on a MenuStrip or ContextMenuStrip. ![]() The MenuStrip, ToolStripMenuItem, ContextMenuStrip controls are used to create menu bars and context menus efficiently.Ĭlick the following links to check their details − Sr.No. Windows Forms contain a rich set of classes for creating your own custom menus with modern appearance, look and feel. When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window − 'adding the menu items to the main menu barĭim myMenuItemNew As New MenuItem("&New")ĭim myMenuItemOpen As New MenuItem("&Open")ĭim myMenuItemSave As New MenuItem("&Save") 'defining the menu items for the main menu barĭim myMenuItemFile As New MenuItem("&File")ĭim myMenuItemEdit As New MenuItem("&Edit")ĭim myMenuItemView As New MenuItem("&View")ĭim myMenuItemProject As New MenuItem("&Project") Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Let's double click on the Form and put the following code in the opened window. The File menu has the sub menus New, Open and Save. Let us create a typical windows main menu bar and sub menus using the old version controls first since these controls are still much used in old applications.įollowing is an example, which shows how we create a menu bar with menu items: File, Edit, View and Project. However, the old control classes are retained for both backward compatibility and future use. Now, the MenuStrip, the ToolStripMenuItem, ToolStripDropDown and ToolStripDropDownMenu controls replace and add functionality to the Menu-related controls of previous versions. Traditionally, the Menu, MainMenu, ContextMenu, and MenuItem classes were used for adding menus, sub-menus and context menus in a Windows application. In this chapter, let us study the following concepts −Īdding menus and sub menus in an applicationĪdding the cut, copy and paste functionalities in a formĪdding Menus and Sub Menus in an Application ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |