Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2008

Tip: Looking for answers? Try searching our database.

VB.Net Standard Control Appearance Problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 19 May 2008 16:08 GMT
I am used to using third party controls when it comes to setting up
appearences. But, now I am using Visual Basic.Net controls that come standard
with the product. I've come across a frustration situation with the combo box
and text box controls.

I setup the text box control appearence settings the way I want the control
to appear. Basically, I have set the "Border Style=FixedSingle", which
results in the control taking on a flat appearence and a black border around
the control.

Now, I want to make my combo box take on the same appearence, as I like all
of the controls in my application to take on the same characteristics. Now,
for the combo box I look in the Apperance Group and do not find a "Border
Style" property. The only thing clost to it that I see is the
"FlatStyle=Flat", which makes the combo box control appear flat, but the
border of the control is not highlight with a black border, thus both of my
controls look nothing alike.

Now, I have read some books on VB.Net and if I recall correctly, these
controls inherit from the Control class. I would take this to mean that all
the controls take on the same properties and methods as inherited from the
base control class.

But, what I have found is that both the text box and combo box controls have
different Appearence properties and thus I cannot use a common set of
settings to make the controls look the same, using the same appearance
settings. I come from an Access background, and I always give the controls in
my application the same appearance and it makes my application look very
professional.

How can I make the combo box and text box controls take on the same
appearancees so they look to take on the same Appearance characteristics.

If anyone can help me get these two controls to take on the same appearance
characteristics, that would be greatly appreciated.

Greg
Cor Ligthert[MVP] - 20 May 2008 05:37 GMT
Greg,

Be aware that something can be inherited, but also a piece can be shadowed,
which means that the behaviour is changed.

However, maybe this helps

http://www.vb-tips.com/ControlBorder.aspx

Cor

>I am used to using third party controls when it comes to setting up
> appearences. But, now I am using Visual Basic.Net controls that come
[quoted text clipped - 44 lines]
>
> Greg
Joergen Bech <jbech<NOSPAM>@ - 21 May 2008 07:28 GMT
That example would have a few problems in the real world, e.g.

1) It does not enumerate the controls recursively. Only the
controls that are direct children of the form, but not those of
groupboxes, etc.

2) It draws the rectangles on the form, rather than the
textboxes. In other words, the rectangles would be drawn
behind the textboxes. I have not run the sample, but I cannot
see how it could possibly work.

3) If a single pixel of the form background is exposed (i.e.
invalidated by another form moved away from it), all the
textbox borders would be redrawn (or rather, they would not
- see above). If, on the other hand, a textbox on the form
was invalidated (the textbox window - not the value),
nothing would happen, which is the exact opposite of what
is needed.

4) Even if it worked, similar code would have to be written
to handle other control types, i.e. the TypeOf case would
have to be extended.

5) This snippet of code would have to be added to every
form that needed to control its children in this manner.

The correct approach would be to create a "MyTextBox" class
(or whatever) that inherits from TextBox and override some of the
base methods to handle custom drawing and provide properties
for controlling its appearance when dropped on a form.

Regards,

Joergen Bech

>Greg,
>
[quoted text clipped - 55 lines]
>>
>> Greg
Cor Ligthert[MVP] - 21 May 2008 18:00 GMT
Joergen,

It is only meant to show that it can be done.

For the rest, I completely agree with you about this and your other message
in this thread.

I don't think that I can add something to that.

Cor

"Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNOSPAM> schreef in bericht
news:7cf734lbnd6e0i2o40jfoplkuue3n9ntgp@4ax.com...

> That example would have a few problems in the real world, e.g.
>
[quoted text clipped - 96 lines]
>>>
>>> Greg
Joergen Bech <jbech<NOSPAM>@ - 21 May 2008 07:44 GMT
While it is true that System.Windows.Forms.TextBox inherits from
System.Windows.TextBoxBase, which in turn inherits from
System.Windows.Forms.Control, the latter does not provide
properties for controlling the appearance of a control.

The Control class provides a common set of methods and
properties for creating, destroying, sizing, etc. a Windows
control, as well as handling keyboard and mouse inputs.

Most of the stuff is abstract, though, and inherited classes
override many of these in order to handle whatever control
they are wrapping.

In many cases, the controls seen in the .Net toolbox are
wrappers around standard Win32 controls and their appearances
are often at the mercy of the operating system settings.
They were not handwritten from the ground up for the .Net
framework.

Often it requires a great deal of work at the message level to
coerce such controls into a common theme.

Unless you just need to fix a single control, rolling your own is
way too much work. Even if you do decide to do it on your own,
you might run into trouble when you run your app on a differently
themed Windows installation unless you are prepared to customize
*every* control you work with.

Instead of trying to make one control look like the other,
you would probably be better off by either

1) leave the appearance entirely up to the operating system, i.e.
leave all settings related to appearance at their default values, or

2) buy/use a suite of controls (e.g. Infragistics NetAdvantage) that
provide a large toolbox of controls utilizing common appearance
properties across all controls.

Regards,

Joergen Bech

>I am used to using third party controls when it comes to setting up
>appearences. But, now I am using Visual Basic.Net controls that come standard
[quoted text clipped - 33 lines]
>
>Greg

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.