I have a Visual Studio 2022 C# WinForm app. I dropped 4 textboxs from the toolbox onto the form to display status info, and renamed them as shown. I have not set any other property or event.
C#
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
private System.Windows.Forms.TextBox myTime;
private System.Windows.Forms.TextBox myDist;
}
I put the following temp code to get a look at the display font size etc.
Code
myTime.Text = "101.1";
myDist.Text = "1025";The textboxes on the form remain blank. In debug mode each text box shows the correct text, it is just not displaying on the form.
Is ther some method that forces an update or focus or something?

Amit MohantyRank #112 · 20K reputationPosted May 19, 2025, 1:13 AM EDT
Your code should be like this:
public Form1() { InitializeComponent(); myTime.Text = "101.1"; myDist.Text = "1025"; }Sangeetha SRank #212 · 11.4K reputationPosted May 19, 2025, 1:55 AM EDT
private System.Windows.Forms.TextBox myTime;
private System.Windows.Forms.TextBox myDist;
Force Refresh (if needed)
myTime.Invalidate();
myTime.Update();
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent(); // This must come first
myTime.Text = "101.1";
myDist.Text = "1025";
}
}
Sam HobbsRank #107 · 20.5K reputationPosted May 22, 2025, 12:58 PM EDT
You do not say how you renamed them. If you edited the code directly then that is the likely problem. Use the Properties box to rename controls.
A nt Fry6 reputationPosted May 23, 2025, 1:53 PM EDT
Well I feel dumb. My issue was the breakpoint was nested deep in code and it wasn't until the code block exited did the textboxes update :(