views:

390

answers:

2

I am converting my company's VB6 program over to VB.net and I have hit another stupid little roadblock.

The old program had a ListView docked to the left side of the application screen. The user could place the cursor over the right portion of the ListView, the cursor would turn into the SizeWE arrows, then they could drag it, which would resize the ListView.

I am trying to recreate this. As far as I can tell there is no Property called "Resizable," or at least nothing is popping out to me. I do not believe that it is being done in the code.

Is there a property I am missing? If not, is there an easy way to do this within the code? (ie. is there a event that would make my life easier)

I am using Visual Studio 2008.

Please forgive any noobness; .NET is still very new to me and I am the only programmer in the whole company. I am only a year out of school.. Thanks in advance!

Edit: I see how how it was done in the previous program (you always seem to find it once you ask the question, don't you?). The old program had a invisible picture that was only a few pixels wide that when hovered over would change the cursor to SizeWE. You could then drag that invisible picture and that would hit an event that would then change the size of the ListView. This seems rather convoluted. My question still stands: Is there a better way to handle this dragging and resizing?

A: 

You should look into using either a Splitter control, or to use the SplitContainer control.

If you use a Splitter, the easiest way to succeed is this:

  • Add the ListView control to the form, set the Dock property to Left
  • Add the Splitter control to the form, set the Dock property to Left
  • Add a Panel control to the form, set the Dock property to Fill

This will give you a view where the user can resize the ListView and the Panel (in which you can place any other controls you need) will use whatever space is available. If the controls don't behave as you want them (if the Splitter does not end up where you expect for instance), use the Format -> Order -> Send to back command on the controls in the order ListView, Splitter and Panel.

Fredrik Mörk
Ah.... yes.. That would do it.Thank you kindly
Ian Kremer
A: 

Using a SplitContainer will allow you to do this easily. alt text

JTA