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.
///
/// 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.
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?
A nt FryPosted May 23, 2025, 5:53 PM
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 :(
Sam HobbsPosted May 22, 2025, 4:58 PM
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.
Sangeetha SPosted May 19, 2025, 5:55 AM
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";
}
}
Amit MohantyPosted May 19, 2025, 5:13 AM
Your code should be like this: