C# ගැටළුවක් [ Help එකක් ]

මම බෙනා

Well-known member
  • Sep 8, 2012
    5,428
    970
    113
    ලංකාවේ
    C# ගැටළුවක් [ Help එකක් ]


    මචන්ලා Textbox1 වල තියෙන Text එකක word එකක් Select කරාම ඒක Textbox2 එකෙත් Highlight වෙලා පේන්ඩ ඕනි... :nerd:

    මේ ඉමේජ් එකේ වගේ...
    :)

    3juO5.jpg


    Textbox1 ඒකේ තියෙන ටෙක්ස් එකමයි Textbox2 එකෙත් තියෙන්නේ..ඒක ශේප් :P

    කොහොමද මේක කරන්නේ...
    :baffled: :rolleyes:
     

    DjSpK

    Well-known member
  • Nov 4, 2008
    5,298
    1,005
    113
    I'm Looking for Me !
    Code:
    private void TextBox1_MouseUp(object sender, MouseEventArgs e){
    	if (TextBox1.SelectionLength > 1) {
    		TextBox2.Select(Strings.InStr(TextBox2.Text, TextBox1.SelectedText, CompareMethod.Text) - 1, TextBox1.SelectionLength);
    		TextBox2.Focus();
    	}
    }
     
    • Like
    Reactions: මම බෙනා

    මම බෙනා

    Well-known member
  • Sep 8, 2012
    5,428
    970
    113
    ලංකාවේ
    Code:
    private void TextBox1_MouseUp(object sender, MouseEventArgs e){
        if (TextBox1.SelectionLength > 1) {
            TextBox2.Select(Strings.InStr(TextBox2.Text, TextBox1.SelectedText, CompareMethod.Text) - 1, TextBox1.SelectionLength);
            TextBox2.Focus();
        }
    }


    Code:
      private void textBox1_TextChanged(object sender, EventArgs e)
            {
                String A = textBox1.Text.Trim();
                textBox2.Text = (A);
                
            }
    
            private void textBox1_MouseUp(object sender, MouseEventArgs e)
            {
                if (textBox1.SelectionLength > 1)
                {
                    textBox2.Select([COLOR=Red]Strings[/COLOR].InStr(textBox2.Text, textBox1.SelectedText, [COLOR=Red]CompareMethod[/COLOR].Text) - 1, textBox1.SelectionLength);
                    textBox2.Focus();
                }
            }


    මචන් මේ Red කරලා තියෙන තන් වලින් මේ Errors 2ක එනවනේ... :sorry:



    • System.Linq.Strings' is inaccessible due to its protection level
    • The name 'CompareMethod' does not exist in the current context
     

    chathuranga8887

    Active member
  • Nov 9, 2009
    583
    72
    28
    mawanella
    Code:
    if (String.IsNullOrEmpty(txtSearchTExt.Text))
                {
                }
                else
                {
    
                    Int32 INDEX = 0;
    
                    String Temp = richTextBox1.Text;
                    richTextBox1.Text = Temp;
    
                    while (INDEX < richTextBox1.Text.LastIndexOf(txtSearchTExt.Text))
                    {
    
                        richTextBox1.Find(txtSearchTExt.Text, INDEX, richTextBox1.Text.Length, RichTextBoxFinds.None);
                        richTextBox1.SelectionBackColor = Color.Yellow;
                        INDEX = richTextBox1.Text.IndexOf(txtSearchTExt.Text, INDEX) + 1;
    
                    }
    
                }

    ZBTCC9F.png


    View attachment WindowsApplication4.zip
     
    Last edited:
    • Like
    Reactions: මම බෙනා

    මම බෙනා

    Well-known member
  • Sep 8, 2012
    5,428
    970
    113
    ලංකාවේ
    Code:
    if (String.IsNullOrEmpty(txtSearchTExt.Text))
                {
                }
                else
                {
    
                    Int32 INDEX = 0;
    
                    String Temp = richTextBox1.Text;
                    richTextBox1.Text = Temp;
    
                    while (INDEX < richTextBox1.Text.LastIndexOf(txtSearchTExt.Text))
                    {
    
                        richTextBox1.Find(txtSearchTExt.Text, INDEX, richTextBox1.Text.Length, RichTextBoxFinds.None);
                        richTextBox1.SelectionBackColor = Color.Yellow;
                        INDEX = richTextBox1.Text.IndexOf(txtSearchTExt.Text, INDEX) + 1;
    
                    }
    
                }
    ZBTCC9F.png


    View attachment 58595


    තැන්ක් මචන් රිපල්යි එකට,මෙතනදි වෙන්නේසර්ච් කිරීමක් වගේ දෙයක් නේ...අපි textbox1 ටයිප් කරන දේ textbox2 එකේ පෙන්නන එකනේ..මට ඕනි මචන් textbox1

    එකේ අපි සිලෙක් කරන එක,textbox2 එක්ත් හයිලයිට් වෙලා පෙන්ඩ..මේ ඉමේජ් එකේ වගේ
    Rep 5+

    3juO5.jpg