C
C#2mo ago
WolfDen133

Winforms control not updating on window resize

Hiya, theres an interesting thing that happens with my winforms application, im setting positions with code as its the aproach i know best but have encountered a weird issue where the position will not visually update, even after calling invalidate and update
1 Reply
WolfDen133
WolfDen133OP2mo ago
It only updates after I move the window
private void MainWindow_ResizeEnd (object sender, EventArgs e)
{
if (!Visible) return;

SuspendLayout();
Toolbar.DoResize(); // Code to resize the element
ViewManager.GetSelectedView().OnResize();

Toolbar.Invalidate(); // Update it visually
Toolbar.Update(); // And update the element
ResumeLayout();
}
private void MainWindow_ResizeEnd (object sender, EventArgs e)
{
if (!Visible) return;

SuspendLayout();
Toolbar.DoResize(); // Code to resize the element
ViewManager.GetSelectedView().OnResize();

Toolbar.Invalidate(); // Update it visually
Toolbar.Update(); // And update the element
ResumeLayout();
}
public void DoResize ()
{
int height = Loader.MainWindow.Toolbar.Height - 6;
int width = (int)(Loader.MainWindow.Toolbar.Width / 4.85f);

Top = 3;
Height = height;
Width = Math.Min(width, 400);

iconPanel.Width = Height - 6;
iconPanel.Height = Height - 8;
iconPanel.Left = (ClientSize.Width - (iconPanel.Width + 3));

titlePanel.Left = titlePanel.Top = 3;
titlePanel.Width = Width - iconPanel.Width - 12;
titlePanel.Height = (height / 2);

title.Font = Utils.Font.GetHandleFont((titlePanel.Height / 2) - 5);
title.Width = titlePanel.Width;

version.Left = title.Width;
version.Font = Utils.Font.GetHandleFont(Math.Min(title.Font.Size - 3, 12));
version.Top = title.Height - version.Height - (int)(title.Height / 8f);

author.Top = title.Height;

author.Font = Utils.Font.GetHandleFont(Math.Min(title.Font.Size - 3, 12));

author.Left = (int)(author.Font.Size / 2f);
}
public void DoResize ()
{
int height = Loader.MainWindow.Toolbar.Height - 6;
int width = (int)(Loader.MainWindow.Toolbar.Width / 4.85f);

Top = 3;
Height = height;
Width = Math.Min(width, 400);

iconPanel.Width = Height - 6;
iconPanel.Height = Height - 8;
iconPanel.Left = (ClientSize.Width - (iconPanel.Width + 3));

titlePanel.Left = titlePanel.Top = 3;
titlePanel.Width = Width - iconPanel.Width - 12;
titlePanel.Height = (height / 2);

title.Font = Utils.Font.GetHandleFont((titlePanel.Height / 2) - 5);
title.Width = titlePanel.Width;

version.Left = title.Width;
version.Font = Utils.Font.GetHandleFont(Math.Min(title.Font.Size - 3, 12));
version.Top = title.Height - version.Height - (int)(title.Height / 8f);

author.Top = title.Height;

author.Font = Utils.Font.GetHandleFont(Math.Min(title.Font.Size - 3, 12));

author.Left = (int)(author.Font.Size / 2f);
}
Code the code i have for it its absolutely fine if i update the lil mufu any other way, but resize, NAH
Want results from more Discord servers?
Add your server