Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Get text from listbox text to richtextbox

listbox richtextbox c#

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 googooli86

googooli86

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 09 April 2015 - 12:36 AM

Hi there,

 

I'm making a bible book app where I have listbox, richtextbox and search textbox.

 

I have som problem coding when the listbox text is chosen, It will show the listbox text + custom text in richtextbox.

 

I have done this:

 
private void btnAra_Click(object sender, EventArgs e)
    {
        int index = 0;
        String temp = richTextBox1.Text;
            richTextBox1.Text = "";
        richTextBox1.Text = temp;

        while (index < richTextBox1.Text.LastIndexOf(txtAra.Text))
        {
            richTextBox1.Find(txtAra.Text, index, richTextBox1.TextLength, RichTextBoxFinds.None);
            richTextBox1.SelectionBackColor = Color.Orange;
            index = richTextBox1.Text.IndexOf(txtAra.Text, index) + 1;
        }
    }
 

But since this is going to be a book app, I want the chosen listbox to show a text file in richtexbox and not only 2-3 sentences..

Any tip for what I can do?

 

Updated with this:

 

  private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            

            var str = listBox1.SelectedItem.ToString();
            if (str == "    Yaratılış        Tevrat")
            {
                richTextBox1.Text = str + "\t\r\n\nText here";
            }
            else if (str == "    Mısır'dan Çıkış              (Yasa)")
            {
                richTextBox1.Text = str + "\t\r\n\ncustom text 2";
            }

Edited by googooli86, 09 April 2015 - 12:41 AM.


#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 09 April 2015 - 05:14 AM

I am not sure I understand, but if what you want is choose a file maybe it's better to use a folder browser dialog or a directory tree instead of a listbox (unless the amount of files fits).

 

So, what else? do you know how to to read a file into a rtb?



#3 googooli86

googooli86

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 09 April 2015 - 08:17 AM

If you look at the page http://incil.info, trying to make this into an application. What I've made so far, is like this: https://www.dropbox....5/form.jpg?dl=0






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download