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
BlakeMcKenna
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What type of application are you working with (WPF, Silverlight, ASP.NET web site, ...)?
Avatar of BlakeMcKenna
BlakeMcKenna
Flag of United States of America image

ASKER

Just a vb.net winforms app!
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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
http://www.ultimateprogrammingtutorials.info/2012/12/how-to-create-custom-button-control-in_23.html
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of BlakeMcKenna
BlakeMcKenna
Flag of United States of America image

ASKER

I tried adding a "UserControl" to my app. I rebuilt the solution but I don't see the new control in the ToolBox anywhere...
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.
Avatar of BlakeMcKenna
BlakeMcKenna
Flag of United States of America image

ASKER

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!
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo