Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
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:

C#
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";
          }
Posted
Updated 9-Apr-15 0:11am
v2
Comments
Sinisa Hajnal 9-Apr-15 9:15am    
Check this: https://msdn.microsoft.com/en-us/library/ms228352(v=vs.90).aspx

On list item select, load the relevant file

Also, why do you create temp variable and clearing the textbox only to re-assign the temp immediately after?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900