I am probably doing something wrong. Only be working with programming a short time. I have a database program I am working on. I have 4 panels, each panel contains a datagridview, labels for counting displayed records, and a button for expanding/collapsing. It is calculating the height of the datagridview, adding the header for the buttons and labels on the panel, and calculating the size if it is under my fixed display height. If it reaches the fixed display height it enables the expand button and makes it visible to you can see all the records if you click expand and it calculates the heights and moves the panels up or down depending on the expand/restore setting. The problem I am having it it seems to be stopping on the second if statement with the calculations and not displaying the panels properly on load, leaving a large gap between the 2nd and 3rd panel instead of the 3px that I have specified. Its also moving the 4th panel up when I expand the second panel and down when I recover it. covering a portion of the box when they should all be moving the same direction. Any help would be appreciated. Please excuse my variable names. I refrained from using 1 or 2 letter ones since this will eventually end up being a large project and I don't want to duplicate variable unless they are being used for the same thing.
Hopefully this code attaches
//DataGridViewHeights default
MCPIDGVhi = 162;
MCUtUDGVhi = 162;
MCHWMTDGVhi = 162;
MCORDGVhi = 162;
// Panel default heights
MCPISSY = 190;
MCPUtUSY = 190;
MCPMTHWSY = 190;
MCPORSY = 190;
public void Panel_Expander()
{
MCPIDGH = DgvIntake.ColumnHeadersHeight + DgvIntake.Rows.Cast<DataGridViewRow>().Sum(r => r.Height);
MCUtUDGH = DgvShopMove.ColumnHeadersHeight + DgvShopMove.Rows.Cast<DataGridViewRow>().Sum(r => r.Height);
MCHWMTGH = DgvLoanedOut.ColumnHeadersHeight + DgvLoanedOut.Rows.Cast<DataGridViewRow>().Sum(r => r.Height);
MCORGH = DgvDispose.ColumnHeadersHeight + DgvDispose.Rows.Cast<DataGridViewRow>().Sum(r => r.Height);
if (MCPIEx)
{
PnlIntake.Height = MCPIDGH + 25;
DgvIntake.Height = MCPIDGH;
MCPUtUPY = PnlIntake.Location.Y + MCPIDGH + 28;
}
else
{
if (MCPIDGH<MCPISSY)
{
PnlIntake.Height = MCPIDGH + 25;
DgvIntake.Height = MCPIDGH;
MCPUtUPY = PnlIntake.Location.Y + MCPIDGH + 28;
BtnIntakeExpand.Enabled = false;
BtnIntakeExpand.Visible = false;
}
else if (MCPIDGH>=MCPISSY)
{
PnlIntake.Height = MCPISSY;
DgvIntake.Height = MCPIDGVhi;
MCPUtUPY = PnlIntake.Location.Y + MCPISSY + 3;
BtnIntakeExpand.Enabled = true;
BtnIntakeExpand.Visible = true;
}
}
if (MCPUtUEx)
{
PnlShopMove.Height = MCUtUDGH + 25;
DgvShopMove.Height = MCUtUDGH;
MCPMTHWPY = PnlShopMove.Location.Y + MCUtUDGH + 28;
}
else
{
if (MCUtUDGH<MCPUtUSY)
{
PnlShopMove.Height = MCUtUDGH + 25;
DgvShopMove.Height = MCUtUDGH;
MCPMTHWPY = PnlShopMove.Location.Y + MCUtUDGH + 28;
BtnShopMoveExpand.Enabled = false;
BtnShopMoveExpand.Visible = false;
}
else if (MCUtUDGH>=MCPUtUSY)
{
PnlShopMove.Height = MCPUtUSY;
DgvShopMove.Height = MCUtUDGVhi;
MCPMTHWPY = PnlShopMove.Location.Y + MCPUtUSY + 3;
BtnShopMoveExpand.Enabled = true;
BtnShopMoveExpand.Visible = true;
}
}
if (MCPMTHWEx)
{
PnlOnLoan.Height = MCHWMTGH + 25;
DgvOnLoan.Height = MCHWMTGH;
MCPORPY = PnlOnLoan.Location.Y + MCHWMTGH + 28;
}
else
{
if (MCHWMTGH<MCPMTHWSY)
{
PnlOnLoan.Height = MCHWMTGH + 25;
DgvOnLoan.Height = MCHWMTGH;
MCPORPY = PnlOnLoan.Location.Y + MCHWMTGH + 28;
BtnOnLoanExpand.Enabled = false;
BtnOnLoanExpand.Visible = false;
}
else if (MCHWMTGH>=MCPMTHWSY)
{
PnlOnLoan.Height = MCPMTHWSY;
DgvOnLoan.Height = MCHWMTDGVhi;
MCPORPY = PnlOnLoan.Location.Y + MCPMTHWSY + 3;
BtnOnLoanExpand.Enabled = true;
BtnOnLoanExpand.Visible = true;
}
}
if (MCPOREx)
{
PnlDispose.Height = MCORGH + 25;
DgvDispose.Height = MCORGH;
}
else
{
if (MCORGH<MCPORSY)
{
PnlDispose.Height = MCORGH + 25;
DgvDispose.Height = MCORGH;
BtnDisposeExpand.Enabled = false;
BtnDisposeExpand.Visible = false;
}
else if (MCORGH>=MCPORSY)
{
PnlDispose.Height = MCPORSY;
DgvDispose.Height = MCORDGVhi;
BtnDisposeExpand.Enabled = true;
BtnDisposeExpand.Visible = false;
}
}
PnlIntake.Location = new Point(3, 32);
PnlShopMove.Location = new Point(3, MCPUtUPY);
PnlOnLoan.Location = new Point(3, MCPMTHWPY);
PnlDispose.Location = new Point(3, MCPORPY);
}
Aucun commentaire:
Enregistrer un commentaire