Set the Name property of these menu items the same as their Text. You can refer to my previous article for adding a context menu. contextMenuStrip1 should look as in the first figure above. Add three more menu items in the ContextMenuStrip Font, Forecolor and Backcolor for changing the font, text color and background color of the TextBox. See:Īdd six menu items in the ContextMenuStrip as in default ContextMenuStrip of the TextBox control, Undo, Cut, Copy, Paste, Delete, and "Select All" with three Separators after Undo, Delete and "Select All" menu items. Set the MultiLine property of the TextBox to true and the ContextMenuStrip property to contextMenuStrip1 to override the default ContextMenu (as in the following figure) of the TextBox. FontDialog and ColorDialog controls are used to select font and colors of the TextBox.Ĭreate a new Windows Forms application and drag a TextBox and a ContextMenuStrip control onto the form. In this article I will explain how to customize the default ContextMenu of a TextBox control and add custom menu items for changing Font, ForeColor and BackColor. In a previous article I explained How to create Context Menu in Windows Forms application using C#. In this article I will explain how to customize a default ContextMenu of a TextBox control in a Windows Forms application using C#.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |