How would I setup my controls for the following situation?:
I have a parent-container for example a GroupBox
.
Inside this parent-container I have two similar controls, like for example ListBox
es, next to each other. They both have the same size, so the border between the two of them is exactly in the middle of the GroupBox
.
Now when the GroupBox
is resized, I want the ListBox
es to also be resized, but the two should always be at the same size than the other one. So also the border between the two of them stays in the middle of the GroupBox
.
So, how would I set up the properties for these three controls to achieve my desired behaviours?
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
You need another container. The TableLayoutPanel is the best solution. Use 1 row and 2 columns and dock (Dock = Fill) it in the group box. The width of both columns should be set to 50%. Next you can add your controls in the individual cells and dock them (Dock = Fill)
Perhaps a SplitContainer
with the two-halves set evenly and IsSplitterFixed
set to true
(to stop the user moving it):
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.Run(new Form {
Controls = { new SplitContainer {
Width = 200,
IsSplitterFixed = true,
SplitterDistance = 100,
SplitterWidth = 1,
Dock = DockStyle.Fill,
Panel1 = { Controls = {
new ListBox {
IntegralHeight = false,
Dock = DockStyle.Fill,
BackColor = Color.Blue,
Items = {"abc","def","ghi"}
}
}
}, Panel2 = { Controls = {
new ListBox {
Dock = DockStyle.Fill,
BackColor = Color.Red,
IntegralHeight = false,
Items = {"jkl","mno","pqr"}
}
}
}
}}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With