|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Count lines in multi-line textboxI have a multi line textbox with word wrap enabled. Is it possible to
write code to check if the text of the textbox has continued into the next line and then count the amount of lines? If not possible in a textbox is it possible in a richtextbox? Thanks <zon***@yahoo.com> schrieb:
>I have a multi line textbox with word wrap enabled. Is it possible to Determining the lines as they are being displayed in a textbox control> write code to check if the text of the textbox has continued into the > next line and then count the amount of lines? <URL:http://dotnet.mvps.org/dotnet/faqs/?id=textboxdisplayedlines&lang=en> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> The TextBox.Lines() method searches the text for newline characters, and
returns an array of all the lines found. Dim tempArray() as String tempArray = textBox1.Lines I don't however understand what you mean by checking if text has wrapped into the next line. Regards, Cerebrus. <zon***@yahoo.com> wrote in message Show quoteHide quote news:1140012453.064289.194380@g44g2000cwa.googlegroups.com... > I have a multi line textbox with word wrap enabled. Is it possible to > write code to check if the text of the textbox has continued into the > next line and then count the amount of lines? > > If not possible in a textbox is it possible in a richtextbox? > > Thanks > <zon***@yahoo.com> wrote in message
news:1140012453.064289.194380@g44g2000cwa.googlegroups.com... The code below counts the lines in a text box (called box) taking wrapping >I have a multi line textbox with word wrap enabled. Is it possible to > write code to check if the text of the textbox has continued into the > next line and then count the amount of lines? into account. HTH & greetings, Marius. Private Function CountLines() As Integer Dim g As Graphics = box.CreateGraphics() Dim sf As StringFormat = DirectCast( _ System.Drawing.StringFormat.GenericTypographic.Clone(), _ StringFormat) sf.Alignment = StringAlignment.Near sf.FormatFlags = StringFormatFlags.NoClip Dim charCount As Integer Dim lineCount As Integer Call g.MeasureString(box.Text, _ box.Font, _ New SizeF(box.Width, box.Height), _ sf, charCount, lineCount) g.Dispose() Return lineCount End Function TextBox1.Lines.Count (or .Length), I don't rembmer off the top of my
head.
check point inside "cirkle" (basketball)
Exposing properties of a class within a class Unresponsive UI during lengthy operation ? extending BackgroundWorker ProgressChangedEventArgs Invoking a PictureBox click ? Can't Figure Out Correct Syntax MethodInfo or MethodBase? console.write ThreadPool.QueueUserWorkItem listview checkbox column - toggle image |
|||||||||||||||||||||||