Testing WinForms user control in C#.net
To test our brand new user control, we need to create another project. Then Right-click the solution inside the Solution Explorer and then choose New > Project.
In the Add New Project Window, choose Windows Forms Application and name it EditableLabelDemo. Next, We need to import our control to the Toolbox so we can easily drag it to the form. Once you are presented with a blank windows forms, go to the Toolbox and right-click (You can right-click on the Generals tab to add our control there). Select the option "Choose Items...".
Choose Toolbox Items window, click the Browse button. and We need to browse for the .dll file containing our user control. Browse for the directory where your project was saved.
Go inside the folder of our Windows Control Library project (named EditorLabel) and inside it, enter the bin folder. The DLL file could either be in the Debug or Release folder. Once you found the EditorLabel.dll, select it and click Open. EditorLabel will now show up in the list of selectable controls inside the Choose Toolbox Item Window. Be sure it's checked and then click OK.
Read More:- User Controls in Visual C#.net
Read More:- User Controls in Visual C#.net
Now you will be able to see our user control inside the Toolbox.
Drag an EditableLabel to the form. We can also find the Text property in the Properties Window since we added the Browsable attribute to that property.
Before You hit F5 to run the project, we must first make the EditableLabelDemo project as the startup project. Right-click EditableLabelDemo project within the Solution Explorer and choose Set as StartUp Project.
It will make the name of the startup project bold. Run the project and double click the label. Change the text to whatever you would like and press Enter. Watch because the text of the label updated to whatever you typed within the editable textbox.
- User Controls in Visual C#.net
- How To Press Keyboard Event keys using c#
- C# Mouse Events in Window Application
- How to Dynamically Adding Controls in C# window apps
- Separating Design and Functionality in C# Window Application
- Message Box C#-Trickcode
- [Lambda] Expressions In c#
- LINQ In C#.Net
- How : To Read A Text File In C#
- How to Writing a Text File In C#
- LINQ To SQL Datacontext
- LINQ Aggregate Methods | Visual c#
- Changing the Casing of Strings
- C# | Variable | A tour of the C# language
Post A Comment:
0 comments: