Note that there are some explanatory texts on larger screens.

plurals
  1. POC# can't see text when updating text box
    primarykey
    data
    text
    <p>I was wondering if someone could help me with a little issue I'm having. I'm trying to update a textbox from another class but the text is not showing up on in the textbox even though it is being sent as I have printed it to the screen.</p> <p>The code I'm using is below:</p> <p>Program.cs</p> <pre><code>namespace Search { static class Program { /// &lt;summary&gt; /// The main entry point for the application. /// &lt;/summary&gt; [STAThread] static void Main() { Application.EnableVisualStyles(); try { Application.SetCompatibleTextRenderingDefault(false); } catch (InvalidOperationException e) { } Application.Run(new Form1()); } public static readonly Form1 MainLogWindow = new Form1(); } } </code></pre> <p>HexToASCII:</p> <pre><code>public class HexToASCII { Output o = new Output(); public void hexToAscii(String hex, int textBox) { //Convert the string of HEX to ASCII StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; hex.Length; i += 2) { string hs = hex.Substring(i, 2); sb.Append(Convert.ToChar(Convert.ToUInt32(hs, 16))); } //Pass the string to be output string convertedHex = sb.ToString(); Program.MainLogWindow.UpdateTextBox(convertedHex); } } </code></pre> <p>Form1:</p> <pre><code> private delegate void NameCallBack(string varText); public void UpdateTextBox(string input) { if (InvokeRequired) { textBox2.BeginInvoke(new NameCallBack(UpdateTextBox), new object[] { input }); } else { textBox2.Text = textBox2.Text + Environment.NewLine + input; } } </code></pre> <p>I have tried to run it using a new thread ThreadStart ts = delegate()... but I'm unable to get the textbox to update. Sorry I'm very new to c#, could someone please explain the issue so I can understand it and learn for next time. Many thanks :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload