10/31/2023 0 Comments Max width height stimulsoft![]() TextBox1.Location = New Point(Me.Width / 2 - TextBox1.Width / 2, Me.Height / 2 - TextBox1.Height / 2)ĭim TBox1StrFont As New Font(, )ĭim g As = Me.CreateGraphics()ĭim TBox1StrWidthHeight As = g.MeasureString(TextBox1.Text, TBox1StrFont) TextBox1.Height = CInt(size.Height + 2 * g.MeasureString("0", Control.DefaultFont).Height)ĭim X As Inetger = Me.Width \ 2 - Textbox1.Width \2ĭim Y As Inetger = Me.Height \ 2 - Textbox1.Height \2 ![]() 'Display text boxĭim size As SizeF = g.MeasureString(TextBox1.Text, Control.DefaultFont, TextBox1.Width) You may want to add an arbitrary fudge factor to the width as per that last line. If Slength.Width > sl Then sl = CInt(Slength.Width) Slength = g.MeasureString(s, Control.DefaultFont) To get the width you need to cycle through the lines you are going to display using code like this: Dim sl As Integer = 0ĭim g As Graphics = TextBox1.CreateGraphics You need to add a preliminary calculation for the text box width. This is not exactly what you have described, but it does essentially the same job. You've taught me everything I know but not everything you know. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click Private Sub Label1_TextChanged(sender As Object, e As EventArgs) Handles Label1.TextChanged Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged Label1.Location = New Point(Me.Width / 2 - Label1.Width / 2, Me.Height / 2 - Label1.Height / 2) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load To list all of the fonts on the system, all of the available sizes of the fonts, etc, etc and the user would have to pick and choose what they want and then set the Labels font accordingly. Maybe you mean you want to change the Labels font for some reason? I would imagine you would have to use a listview or something similiar I know you can add fonts to the system for use by applications. I was unaware that a user could change the systems font. ![]() Long before you saved the data for entry into the Label if you use a Label. I would think you would have to do that when the user is entering their data initially. I don't know how you figure out the min 30 characters, max 80 characters thing. The code that follows merely assigns it to new location center Form. If you use a label it automatically expands width and height. Can anybody show me a couple of lines ofĬode that will make the width of the text box change depending on the length of the string of text (min 30 characters, max 80 characters with no text wrapping) and how do I make the height of the box change depending on how many separate lines of text The user may change the system font or screen size when running the program so that has to be accommodated too. The height and width of the box containing the text should change dynamically with the width of the event description and the number of events (each event being on a separate line.) Iĭid this very successfully in in VB6 but cannot figure out how to do it in VB Express 2012. The application should be centered in user's screen. I can do all the math-that's not the problem. I am trying to develop a desktop application for Windows 8 using Visual Studio Express 2012 that when run will display a list of birthdays and other important dates within the next 10 days.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |