Re: [2005] Multiline Label
You change the combobox dropdownstyle to DropDownList so that it wont change.
As for the label, do you mean having a multi-line label?
Label1.Text = "Hello" & Environment.NewLine & "World"
Re: [2005] Multiline Label
Thanks - couple minor things though.
Environment.NewLine isn't exactly what I'm looking for as I'm not sure how long the text will be. What I'd really like is to be able to define the complete area like a textbox, and have word wrap enabled so that the text wraps around. I do not however want the user to be able to edit that text. It's just a label really.
As for the combo box. Thanks a bunch! That's exactly what I want. How do I set the default value though? I can't seem to find that property.
Re: [2005] Multiline Label
You can define the combobox index by code only I think. On form load for example you could put this:
ComboBox1.SelectedIndex = 4
I'm not sure about the label. If you want to stop the input from a user on a textbox you could add this code and stop user input:
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
e.Handled = True
End Sub
would set the 5th value in the combobox as the default
Re: [2005] Multiline Label
Awesome - that's working great. :) Thanks a ton. That code for the Textbox is working. Is there something similar you can do to disable mouseclicks? Right now you can still click in there, highlight the text etc which is a bit goofy.
Re: [2005] Multiline Label
I'm silly, the textbox control has a ReadOnly property which you could change to True.
That way you wouldn't have to add any code. Although having just tried it, it also allows the mouse to select text.
There's probably an easier way but you could add code for stopping mouse click by setting focus to a label instead.
So, if you have a control like a label that doesn't do anything you could write:
VB Code:
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
Label1.Select()
End Sub
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
Label1.Select()
End Sub
And so on... although there is probably a better way.
Re: [2005] Multiline Label
If you are going to use a textboxt to simulate a label, you should keep it from looking like a textbox. Nothing is more annoying than a textbox that you can't touch. You can make the textbox look like a label by adjusting the backcolor and the style. I think the 2D, flat, or borderless (or something like that) style would appear the same as a label.
I can't remember a lable that wasn't automatically multi-line if it was created big enough to hold multiple lines. Has that changed? I guess I haven't tried that recently, but I'd be surprised if that was taken away.
Re: [2005] Multiline Label
I already changed the color/border etc to match the background. It doesn't look like a textbox at all. It's a bit goofy that you can highlight the text in it and if you click on it a little curser will start blinking, but 99% of the time I don't think a user will try to do that. Nor does it really affect the program if they do.
Edit: I forgot to mention that unfortunately that mouse code doesn't seem to work. :cry: It's ok though - I can live with it in its current state.
Re: [2005] Multiline Label
I've just checked again and the mouse code does work.
Did you try it with the MouseDown event on the textbox?
I added that after the initial post.
Re: [2005] Multiline Label
Haven't been able to test 2005, but I have tested 2003, and labels all automatically wrap text. Has that changed in 2005?
Re: [2005] Multiline Label
Well I can't test it with 2003 as I don't have it but in 2005 - they don't wrap.
Edit: Stimbo - thx for all the help. It didn't look like it worked because I changed the label1 to textbox1... which needless to say didn't work. I switched it to ok_button.select() and now it's working great.
Re: [2005] Multiline Label
Labels DO wrap in 2005. The AutoSize property is True by default, so if you add more text then the Label will grow to accommodate it. Set the AutoSize property to False and the text will wrap if it is too long to fit the current Width.
Re: [2005] Multiline Label
LOL Well.... all that work for nothing. :) Thanks for the info jm.