[RESOLVED] [2005] This.Height strangeness
I have a form that has no titlebar at all (no .Text property and ControlBox set to false)
I am trying to set its .Height to 18 which displays properly in the IDE, but when I run the app, it is being set to something like 24 and no matter what I do I cannot seem to force it to be only 18.
Has anyone seen this and/or can duplicate and then discover a workable solution?
I have this size for a reason and it is driving me crazy!
Re: [2005] This.Height strangeness
mmmm I'm presuming that this wasn't supposed to be in asp.net but...
Just had a play around as it sounded interesting and i found I could only get the form to display as 18 height if i set a low minimumsize.height (in this case 5). But as soon as I set minimumsize.height to 0 (default and should mean there is no minimum height) the form displays at 24 again.
Does that help with your problem?
Re: [2005] This.Height strangeness
Yes, this should have been in C#, not ASP.Net. Wish I could move it myself. Sorry about that folks.
I found the same, but as soon as it is moved, it resets back.
Here is the code that lets you move the form btw (so you can test it) (my form being named frmTitleBar:
Code:
bool bIsDragging = false;
System.Drawing.Point oSourcePoint = new Point(0, 0);
private void frmTitleBar_MouseDown(object sender, MouseEventArgs e)
{
bIsDragging = true;
oSourcePoint = new Point(e.X, e.Y);
}
private void frmTitleBar_MouseUp(object sender, MouseEventArgs e)
{
bIsDragging = false;
}
private bool bHandlingMove = false;
private void frmTitleBar_MouseMove(object sender, MouseEventArgs e)
{
if (bHandlingMove == false)
{
bHandlingMove = true;
if (bIsDragging)
{
this.SetDesktopLocation(
this.DesktopLocation.X - (oSourcePoint.X - e.X),
this.DesktopLocation.Y - (oSourcePoint.Y - e.Y)
);
}
System.Windows.Forms.Application.DoEvents();
bHandlingMove = false;
}
}
Re: [2005] This.Height strangeness
I guess setting the maximum size coerced it to stay the size I need. Ill mark resolved for now, but I am not quite satisified because this means I am going to end up with a huge coding nightmare once I implement being able to resize it horizontally (which I will eventually be getting to).
Thanks Fishy.
Re: [2005] This.Height strangeness
Quote:
Originally Posted by Lord_Rat
I guess setting the maximum size coerced it to stay the size I need. Ill mark resolved for now, but I am not quite satisified because this means I am going to end up with a huge coding nightmare once I implement being able to resize it horizontally (which I will eventually be getting to).
Thanks Fishy.
Sorry I know you marked as resolved but after copying your code I can move the form around the screen without it reverting to a height of 24 and I haven't got any maximum size set. Just a min height of 1.
Re: [RESOLVED] [2005] This.Height strangeness
Mine pops back open. I have some buttons docked to the right, I suppose its the existance of my child controls causing that to happen. I also have a panel docked left (which is used to move the control - it passes mouse move, down and up commands to the form's same commands) and a panel docked FULL in the middle with a text box also docked full. I am using a font of Tahoma, size 7 as the form default font.
It occurs to me that I can set the maximum size height-only I beleive. If so, this will do nicely.