4 Replies - 651 Views - Last Post: 30 March 2013 - 05:05 AM Rate Topic: -----

#1 fatihmert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 04-March 12

[QUESTION] Textbox Selected text another tag don't added

Posted 25 March 2013 - 12:15 PM

Hi guys, It's again me :) I want create simple html list menu with textbox component.

input:
Forums
Programming
Web Development
Computers



String secili = textBox1.SelectedText;
List<String> yeni = new List<string>();
yeni.Add(secili);
foreach (string s in yeni) {
        textBox1.SelectedText = String.Format("<li>{0}</li>",s);
}



output:
<li>Forums
Programming
Web Development
Computers</li>



Selected text is read to string type. I don't want it. I want it;

output:
<li>Forums</li>
<li>Programming</li>
<li>Web Development</li>
<li>Computers</li>



How do I can it?

Thank you for interest.
Good works..

Is This A Good Question/Topic? 0
  • +

Replies To: [QUESTION] Textbox Selected text another tag don't added

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3522
  • View blog
  • Posts: 12,026
  • Joined: 12-December 12

Re: [QUESTION] Textbox Selected text another tag don't added

Posted 25 March 2013 - 12:38 PM

TextBox.SelectedText will be a single string, which is why you get your current result.

Assuming your textbox is multiline, and the selected text includes a number of lines, then you might use Split() to split this string at the newline characters. Then you can use List.AddRange() to add all these (individual) lines/strings to your list.

When you then iterate this list you'll need to construct a new string, with each line appended to the previous line, using concatenation.

For your LIs to be valid HTML they should be enclosed in an OL or UL tag.

I'm not sure why you are trying to create an HTML-list within a textbox(?).
Was This Post Helpful? 1
  • +
  • -

#3 fatihmert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 04-March 12

Re: [QUESTION] Textbox Selected text another tag don't added

Posted 25 March 2013 - 12:54 PM

Only developing myself. I can think of trying to make leaders. Thank you for your interest or I couldn't learn.

I forgot String[] array type(s) so I can use List type.

When it reads secili.Split() Web Development 2 lines. As such objects may have more than one argument. So, Think we need to follow a different path.

Thank you for interest.
Good works..
Was This Post Helpful? -1
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,866
  • Joined: 02-June 10

Re: [QUESTION] Textbox Selected text another tag don't added

Posted 25 March 2013 - 01:12 PM

Andrew said to split on the new line character, not just the default split which is on the space.
Take the time to actually READ THE MSDN PAGE ON .SPLIT so you have a better idea about the tools you're trying to use.

View Postandrewsw, on 25 March 2013 - 01:38 PM, said:

split this string at the newline characters

Was This Post Helpful? 1
  • +
  • -

#5 fatihmert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 04-March 12

Re: [QUESTION] Textbox Selected text another tag don't added

Posted 30 March 2013 - 05:05 AM

Omg,I forget that on Python :) I solved..

Regex.Split(object_, "\r\n")

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1