F
--Fragman--
I'm trying to use the HScrollBar and VScrollBar controls, but I'm
having some problems with them...
I want them to just sit there and let the user drag them, so I can
retrieve the thumb position and handle everything else in my code.
Furthermore, I want to control when they appear and when not.
I have two values, h.iSizeX and h.iSizeY, which represent my drawing
area, however, main form can be larger or smaller. If smaller, I want
to show scrollbar(s), if larger, I just want to resize my drawing area
panel.
Here's my current code:
scr_h.Left = toolStrip1.Width;
scr_h.Top = Height-scr_h.Height;
scr_v.Left = Width-scr_v.Width;
scr_v.Top = menuStrip1.Height;
if (h.iSizeX > Width - toolStrip1.Width)
{
pnl_Render.Width = Width - toolStrip1.Width;
scr_h.Visible= true;
scr_h.Enabled = true;
scr_h.Maximum = h.iSizeX;
}
else
{
scr_h.Visible = false;
pnl_Render.Width = h.iSizeX;
}
if (h.iSizeY > Height - menuStrip1.Height)
{
pnl_Render.Height = Height - menuStrip1.Height;
scr_v.Visible = true;
scr_v.Enabled = true;
scr_v.Maximum = h.iSizeY;
}
else
{
scr_v.Visible = false;
pnl_Render.Height = h.iSizeY;
}
Problems with it:
-Right now only the VScrollbar shows up when intended, but I can't see
why.
-The Width on VScrollbar and the Height on HScrollbar values seem to be
wrong, since the VScrollbar appears too far on the right and only half
of it is shown on the right side of the window. I can already notice
that when in designer.
Any ideas on how to get that working?
having some problems with them...
I want them to just sit there and let the user drag them, so I can
retrieve the thumb position and handle everything else in my code.
Furthermore, I want to control when they appear and when not.
I have two values, h.iSizeX and h.iSizeY, which represent my drawing
area, however, main form can be larger or smaller. If smaller, I want
to show scrollbar(s), if larger, I just want to resize my drawing area
panel.
Here's my current code:
scr_h.Left = toolStrip1.Width;
scr_h.Top = Height-scr_h.Height;
scr_v.Left = Width-scr_v.Width;
scr_v.Top = menuStrip1.Height;
if (h.iSizeX > Width - toolStrip1.Width)
{
pnl_Render.Width = Width - toolStrip1.Width;
scr_h.Visible= true;
scr_h.Enabled = true;
scr_h.Maximum = h.iSizeX;
}
else
{
scr_h.Visible = false;
pnl_Render.Width = h.iSizeX;
}
if (h.iSizeY > Height - menuStrip1.Height)
{
pnl_Render.Height = Height - menuStrip1.Height;
scr_v.Visible = true;
scr_v.Enabled = true;
scr_v.Maximum = h.iSizeY;
}
else
{
scr_v.Visible = false;
pnl_Render.Height = h.iSizeY;
}
Problems with it:
-Right now only the VScrollbar shows up when intended, but I can't see
why.
-The Width on VScrollbar and the Height on HScrollbar values seem to be
wrong, since the VScrollbar appears too far on the right and only half
of it is shown on the right side of the window. I can already notice
that when in designer.
Any ideas on how to get that working?