hide and resize controls
-
im hiding the groupbox and i want to fill the empty space with datagrid that is still visible. how do resize the datagrid to feet the space, is there a easy way?
You can simply assign a new
Location
andSize
property to any control to alter its appearance:grpBox.Hide();
dataGrid.Location = grpBox.Location;
dataGrid.Size = grpBox.Size;Regards, mav
-
You can simply assign a new
Location
andSize
property to any control to alter its appearance:grpBox.Hide();
dataGrid.Location = grpBox.Location;
dataGrid.Size = grpBox.Size;Regards, mav
-
i dont understand why 1.) dataGrid1.Size = groupBox3.Size + dataGrid1.Size; work and... 2.) dataGrid1.Size.Height = groupBox3.Size.Height + dataGrid1.Size.Height; dont i wanna change only dataGrid1 Height
The
Size
object is immutable. That means that once created it does not change. You cannot set theHeight
of aSize
object because that would change the object, you have to create a newSize
object and use that - which is why your example 1 worked.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
The
Size
object is immutable. That means that once created it does not change. You cannot set theHeight
of aSize
object because that would change the object, you have to create a newSize
object and use that - which is why your example 1 worked.
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
can you help me please ...am learning not workink code: groupBox3.Hide(); dataGrid1.Location = groupBox3.Location; dataGrid1.Size.Height = groupBox3.Size.Height + dataGrid1.Size.Height;
As I said already: The
Size
object is immutable. That means that once created it does not change. You cannot set theHeight
of aSize
object because that would change the object, you have to create a new Size object and use that In your code that means the linedataGrid1.Size.Height = groupBox3.Size.Height + dataGrid1.Size.Height;
cannot work because you are attempting to set the Height property on an immutable object. (If the property is on the left hand side [LHS] of the equals operator then that is a set operation, if the property is on the right hand side [RHS] of the equals operator then that is a get operation) So, going back to what I said, you have to create a new
Size
object. Something like this would workSize newSize = new Size(dataGrid1.Size.Width, groupBox3.Size.Height+dataGrid1.Size.Height);
dataGrid1.Size = newSize;By the way, you should really attempt to name your controls (and all variables) with sensible names. groupBox3 and dataGrid1 are not self-explanatory. You will have difficulty in determining what you were trying to do if you come back to look at the code later. Does this help?
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
im hiding the groupbox and i want to fill the empty space with datagrid that is still visible. how do resize the datagrid to feet the space, is there a easy way?
You could put the groupbox in a panel, and then when you hide the groupbox, set the Dock property of the datagrid to DockStyle.Fill
-
As I said already: The
Size
object is immutable. That means that once created it does not change. You cannot set theHeight
of aSize
object because that would change the object, you have to create a new Size object and use that In your code that means the linedataGrid1.Size.Height = groupBox3.Size.Height + dataGrid1.Size.Height;
cannot work because you are attempting to set the Height property on an immutable object. (If the property is on the left hand side [LHS] of the equals operator then that is a set operation, if the property is on the right hand side [RHS] of the equals operator then that is a get operation) So, going back to what I said, you have to create a new
Size
object. Something like this would workSize newSize = new Size(dataGrid1.Size.Width, groupBox3.Size.Height+dataGrid1.Size.Height);
dataGrid1.Size = newSize;By the way, you should really attempt to name your controls (and all variables) with sensible names. groupBox3 and dataGrid1 are not self-explanatory. You will have difficulty in determining what you were trying to do if you come back to look at the code later. Does this help?
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
You could put the groupbox in a panel, and then when you hide the groupbox, set the Dock property of the datagrid to DockStyle.Fill