Hack Forums
[C#] [FIXED] prevent richtextbox from displaying the same string after the second time run - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [FIXED] prevent richtextbox from displaying the same string after the second time run (/showthread.php?tid=5981983)



[FIXED] prevent richtextbox from displaying the same string after the second time run - Iera Namhorun - Jun 21, 2019

I tried to display the string into the richtextbox, but always got the same or duplicate string after the second time it was run as in example of displaying a second string.

Example of displaying the first string:
Quote:[21:55:07] - [-] Starting scanning, please wait. . .

[21:55:09] - [-] Finished.



Example of displaying a second string:
Quote:[21:55:07] - [-] Starting scanning, please wait. . .

[21:55:09] - [-] Finished.

[21:55:07] - [-] Starting scanning, please wait. . .

[21:55:09] - [-] Finished.


code :
Spoiler (Click to View)

I have tried adding
Code
if (DisplayTextBox.Text ! = null)
   {
      DisplayTextBox.Clear();
    }
but still there is no change, the second time the scan button is run it will bring up the same two strings.

How do I prevent it from displaying duplicate strings like in the example second string?
I want to display strings like in the example of the first string display.



[FIXED]
I try to use Application.Restart(); to restart Form into its original state as well to prevent displaying the same string again.
And log all the strings to text file using Streamwriter


RE: [FIXED] prevent richtextbox from displaying the same string after the second time run - NYANxCAT - Jun 22, 2019

are you using check for cross-thread before calling the backgroundworker? ??
because you can't use the richtextbox without invoking it to UI thread.

if you don't want to invoke it, then add "CheckForIllegalCrossThreadCalls = false;" inside your Form1_Load.


RE: [FIXED] prevent richtextbox from displaying the same string after the second time run - Washi - Jun 22, 2019

(Jun 22, 2019 07:06 AM)˗ˏˋ NYAN CAT ˎˊ˗ Wrote:  are you using check for cross-thread before calling the backgroundworker? ??
because you can't use the richtextbox without invoking it to UI thread.

if you don't want to invoke it, then add "CheckForIllegalCrossThreadCalls = false;"  inside your Form1_Load.

Unless very specific circumstances are applicable (great emphasis on the word "very" here), nobody should ever use the CheckForIllegalCrossThreadCalls property, ever.


RE: [FIXED] prevent richtextbox from displaying the same string after the second time run - NYANxCAT - Jun 22, 2019

(Jun 22, 2019 09:47 AM)Washi Wrote:  Unless very specific circumstances are applicable (great emphasis on the word "very" here), nobody should ever use the CheckForIllegalCrossThreadCalls property, ever.

I agree with you.


RE: [FIXED] prevent richtextbox from displaying the same string after the second time run - Iera Namhorun - Jun 26, 2019

(Jun 22, 2019 07:06 AM)˗ˏˋ NYAN CAT ˎˊ˗ Wrote:  are you using check for cross-thread before calling the backgroundworker? ??
because you can't use the richtextbox without invoking it to UI thread.

if you don't want to invoke it, then add "CheckForIllegalCrossThreadCalls = false;"  inside your Form1_Load.

I don't use it, thank you for the information and I will try to fix it again 😉