3 Replies - 247 Views - Last Post: 22 October 2017 - 03:38 PM Rate Topic: -----

#1 Luseres  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-October 17

Set specific line of RichTextBox to string

Posted 22 October 2017 - 11:28 AM

Hello DreamIncode users,
I am trying to set a line from a richtextbox to a string,
Im tryd using the following code:
 Form1.MenuX.Lines(selectedline).Text = content 

but this doesnt seem to work because the .Lines(selectedline) doesnt have .Text...
Is there any way you guys can help me to set a specific line of an richtextbox?
also I have an String for content and Integer for selectedline.

~ Luseres


Is This A Good Question/Topic? 0
  • +

Replies To: Set specific line of RichTextBox to string

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13482
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: Set specific line of RichTextBox to string

Posted 22 October 2017 - 11:45 AM

What is '.lines'? It's a string array, right? From the MSDN docs. There is no .text for a string.

Is form1 a variable name for an instance of your form class?

https://msdn.microso...(v=vs.110).aspx
https://msdn.microso...(v=vs.110).aspx
Was This Post Helpful? 0
  • +
  • -

#3 Luseres  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-October 17

Re: Set specific line of RichTextBox to string

Posted 22 October 2017 - 11:48 AM

.lines gets the lines from the richtextbox and form1 is the name of 1 of my forms I have 2, Form1 and Data the
Form1.MenuX.Lines(selectedline).Text = content

code is in the Data form so it has to change the richtextbox lines in Form1
MenuX is my richtextbox

This post has been edited by andrewsw: 22 October 2017 - 03:27 PM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6374
  • View blog
  • Posts: 25,755
  • Joined: 12-December 12

Re: Set specific line of RichTextBox to string

Posted 22 October 2017 - 03:38 PM

The Lines property should be considered readonly. To replace the text of a line you can use the index to select, and replace, its text. There is some code to explore here (although in C#).

If the line numbers have significance, and you don't need rich-text formatting, then you might consider a ListBox instead.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1