[Testing] WinForms user control in C#.net

Windows Control Library project,Windows Forms Application,WinForms user control in C#
Share it:

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.

Testing WinForms user control in C

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...".

 Windows Forms Application

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

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.
Properties Window


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.

Read More:-

Share it:

Windows Forms

Post A Comment:

0 comments: