Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America asked on

How to create a custom label control?

Here is the issue that I am having. I have a program that allows users to control the look and feel of the various controls on the forms, i.e. BoldText, Italics, Back/Fore Colors, etc.

Some of the functionality uses Label Controls as a "System Message" (usually large fonts and a distinct background color). My problem is that if a user decides to change all the Label controls to be Bold or Italics, this effects the "System Message" Bold and/or Italics properties, which brings me to creating a custom Label control. I've been playing around with the creation of a "UserControl" but I've never created one before so I'm not sure how to create a New Label control that contains FontSize, Bold, etc properties.
Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon
Bob Learned

What type of application are you working with (WPF, Silverlight, ASP.NET web site, ...)?

Just a vb.net winforms app!
Bob Learned

With Windows Forms, if you create a control library project, and add a custom class, the control will inherit the Font property.

Here is some good reading material on custom controls in Windows Forms.

How To Create A Custom Button Control In VB.NET
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jacques Bourgeois (James Burger)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I tried adding a "UserControl" to my app. I rebuilt the solution but I don't see the new control in the ToolBox anywhere...
Jacques Bourgeois (James Burger)

It usually shows in a tab with the name of your project, at the top of the Toolbox.

And if you did it with code similar to mine, it's not a UserControl, but an inherited control (some say a custom control).

A UserControl is interesting when you need a group of controls working together in a specific way. It's not really a control, its more like a small form that you can insert into another form.

An inhnerited control is better for what you want to do because it is a real control, is easier to manipulate through code, and offers more possibilities once you've learned all the tricks that you can do with inheritance.

I see what your saying James. I'll give this a try. It definitely makes more sense. Not sure where I was trying to go but thanks for the help!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.