Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Text vertically on a Button

Status
Not open for further replies.

dougconran

Technical User
Sep 26, 2003
89
GB
Is there any way of displaying text vertically rather than horizontally on a button. ie:

S
A
V
E

instead of SAVE.

In VB6 you can do this by separating each character with a space, I guess wraparound then kicks in and wraps the word, effectively, vertically. This doesn't work in .Net (Compact Framework)

TIA

Doug
 
you could try setting the .text property at runtime to:

Code:
btn1.text = "S" & controlchars.cr & _
            "A" & controlchars.cr & _
            "V" & controlchars.cr & _
            "E"

-Rick

----------------------
 
Actually I had tried doing this before and I had to use

Code:
ControlChars.CrLf

or 

vbCrlf

to get it working this way. It needs a Carriage return and a linefeed character to do this.

-Kris
 
This is still not working although I've tried all combinations of vbcrlf, controlchars.crlf and controlchars.cr.

What is happening is that only the first character (S) is being displayed although the full (vertical) string is stored in the button text field (I can display it with messagebox).

I'm using the Compact framework on a pda and so screen space is at a premium and I really need to get this to display vertically, any other ideas?

TIA

Doug
 
Doug,
If I understand you correctly, the result may depend on the size (aspect ratio) of your button.

In fact, I have tried it your VB6 way, and it works well simply by squeezing the button to be a long vertical rectangle, and the wrapping kicks in to make a vertical text. By making progressively more spaces between the letters, I manage to get wider buttons (buttons 1 to 3).

Then I tried a big fat button, erased the text to start with, but I set the text by code, as follows:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Button4.Text = "S" & vbCrLf & "A" & vbCrLf & "V" & vbCrLf & "E" & vbCrLf
End Sub

When I click on the button, the vertical text
S
A
V
E
appears on the button, even though the button is much wider.

This is what I got:
VerticalButton.jpg
 
PC888 - thanks for your efforts here but no, it seems to depend on whether it is using the Compact Framework or not. The vertical text works quite happily (in fact better than VB6 because you don't need to intersperse with spaces) for a standard PC (is that the standard Framework?) but refuses to do anything other than show the first character on the button when run in the compact framework. I deduce from this that anything that is not a standard alphanumeric is treated as the end of text.

Like I say, it looks like (yet another) limitation of the compact framework and I'm going to have to find a way around it by creative code.

I can lay a label over the button and get the text to display vertically but, because it is over the button it is not, then, sensitive to a prod.

Has anyone got any ideas?

TIA

Doug
 
Make a few pictures of the button in the up (unfocused), up (focused) and down positions. then use a picture box to display them. Use the enter/leave and the mouse button down/up events to swap the picture.

-Rick

----------------------
 
Thanks, Rick. I've tried that and it's a bit tedious compared to using a buttn but works well.

Thanks for the advice.

Doug
 
No problem, it's an old trick to give a VB app a non-standard skin. Between that and some API calls you can do some fun stuff in VB 6, I'm sure there's more efficient ways to do the same in the full .Net framework though.

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top