Text in a scroll bar

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Is there a way to put a labe in a scroll bar as oppose to in front of
it. (Ie the scroll goes the text as oppose to under the text)
 
Is there a way to put a labe in a scroll bar as oppose to in front of
it. (Ie the scroll goes the text as oppose to under the text)

Yes, inherit the scrollbar component, override the paint method, and make
it call it's base... then just draw the text wherever you want it.

Then in your app, just use your component instead.
 
I understand the inherit and the override the paint method but be new
to vb.net I am not sure what you mean by call it base
 
I understand the inherit and the override the paint method but be new
to vb.net I am not sure what you mean by call it base

Ok... no problem... let me explain...

So you have the default scrollbar, and you are going to create a new class
that inherits from scrollbar... say call it scrollbarfoo.

ex. Public Class ScrollBarFoo Inherits ScrollBar

Now... if you create an instance of scrollbarfoo, it is going to look like
a normal scrollbar, since you haven't changed anything from the original
scrollbar. But we want some text to appear on it, so we want to override
(replace) the method that 'draws' the scrollbar on the form.

This method is really split into two, there is the onpaintbackground
method and the onpaint event.

So.. create a method that overrides the original onpaint method that
you're inheriting. Since you don't want to go through the hassle of
re-drawing the entire scrollbar (and you don't want to believe me), the
first thing you're going to do is to call the original onpaint method (the
one you're replacing)... this will draw the usual scrollbar for you, now
all you need to do is continue to add any other graphics that you want..
in your case, you want to use the Graphics.DrawString method.

The command you want to use to call the base class is MyBase
 
Is there a way to make a checkbox (button style) that is triangular
shaped?

Yes of course, inherit the normal checkbox and totally replace (override)
its paint method. That is all you need to do really since the rest of the
functionality would still be the same, you're just changing the way it
draws itself.
 
And is there a way to override the onPaint method of a ComboBox, I
tried this and it seems that the OnPaint method is never called for a
ComboBox, I might be wrong, but I can do the exact same thing for a
Textbox and it works.

Also, do you know what is the control that is used for the button of
the comboBox, because it seems to change with Windows Theme, but it
does not look like a regular button.

Thanks
 
Back
Top