Splitter Usage

  • Thread starter Bruce Schechter
  • Start date
B

Bruce Schechter

I am creating a Windows Form which will hold two primary controls: a
listview docked on the left and a datagrid docked on the right. I'm putting
a "spliiter" between them, and I had hoped to design it such that the
splitter was tied to both (listview and datagrid). The behavior I desire:
when the user slides the splitter right the listview would expand and the
datagrid would collapse.

But, I havnt achieved that goal. (This is my first try at using the
splitter control.) Apparently, I need to dock the splitter on the left or
right, but that "attaches" it only to one or the other of the listview and
the datagrid.

Question: how can I achieve my goal? Can I somehow attach the splitter to
both controls? Or, should I attach it to one of them and then respond to a
splittermoved event and programmatically change the size of the other
control(which seems feasible but also seems like something I'd like to avoid
if I can.) Or, something else?

Thanks,
Bruce
 
G

Guest

dock one control to the left, and set the dock for the other control to fill. then drag your splitter onto the form

should work then. ;]
 
H

Herfried K. Wagner [MVP]

* "Bruce Schechter said:
I am creating a Windows Form which will hold two primary controls: a
listview docked on the left and a datagrid docked on the right. I'm putting
a "spliiter" between them, and I had hoped to design it such that the
splitter was tied to both (listview and datagrid). The behavior I desire:
when the user slides the splitter right the listview would expand and the
datagrid would collapse.

But, I havnt achieved that goal. (This is my first try at using the
splitter control.) Apparently, I need to dock the splitter on the left or
right, but that "attaches" it only to one or the other of the listview and
the datagrid.

Instead of docking the splitter control, dock the controls to the
splitter.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Bruce,

The way splitter works is it changes the size of the control it is docked
against.
For example:
If you have control docked on left and then splitter docked on left (spliter
is docked against the contol) and you move the splitter it will change the
control's width. The area that remians empty should be filled with the
second control. So, set the seconds control Dock property to fill and the
framework will resize it for you. The splitter doesn't care about the
control on the right.
 
B

Bruce Schechter

Gentlemen,
Thanks to all three of you who answered. You have given me everything I
need to know.
Cheers, Bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top