Simple Toobar question ? perhaps not....

Hi Guys,

I am writing an application that has a number of toolbar buttons along the top. At the end of these buttons I want to position a panel control (that has info in).

I have two test machines. One running XP Home and the other Win2000 professional.

On the XP Machine I use the designer to position the panel directly after the last toolbar button. Compile and transfer to the other test machine.

When I run the application the panel control has moved left and is now covering the last 2 buttons (ie, it has moved left about 50pixels or so).

Testing the other way round (ie, compiling on the Win2000 machine and running on the XP) displays a similar problem, although the panel will have moved right about 50 pixels, leaving a large gap.

To try and solve this I tried dynamically positioning the panel control at run time using toolbar.Items [toolbar.Items.Count - 1].Rectangle.Right, which appears to give the correct positioning value, but again, when run on the other machine produces the wrong position.

Can anyone offer a reason why this is happening and tell me how to position something directly after toolbar buttons Ideally I need it to be directly after the last button.

Thanks for any help

Todd.


Answer this question

Simple Toobar question ? perhaps not....

  • FlashFan

    Hi Erik,

    Thanks for your reply :)

    I am on .Net 1.1. I have to use a panel as it needs to contain other controls (for example, the toolbar has zoom, crop, pan buttons and I want the panel to contain options to do with each button. So for Zoom the panel has a label "zoom" and a textbox allowing you to type in the exact zoom you want. Crop and Pan both have other options)

    I will try your splitter method tonight, but I am a little confused as to why it is happening in the first place. It is fine on the machine it is complied on, but not if I take the executable onto the other OS (ie, win2000 -> XP or XP -> win2000).

    Ive tried dynamically positioning the panel but something must be pre-computed (button size ) as it is always wrong when I swap between OSs. I will do a few more tests tonight and post some more info.

    Thanks for your help.

    Todd.

  • Alex More

    Todd,

    I have no idea why this is happening, other than to say that I have seen different behavior when you try to "jury-rig" something between different Windows OS. I must ask, are you positioning the panel within the toolbar, or trying to manually position it external to the toolbar Do you really need a panel here Why doesn't a textbox or label work instead

    If you are on .NET 2.0, then I would suggest you embed the panel within a tool strip directly, using the ToolStripControlHost class. Even better to use the built-in embedded label or text box, but you should be able to host a panel as well. This would then let you use the built-in layout logic and should work across machines.

    If you are on .NET 1.x, this is harder to do. I'm guessing here, but you might look into using a larger Panel docked to the top of the form, with a Splitter control to divide this in half. The left side could then contain your ToolBar class, and the right side your Panel. The Splitter would form a firm dividing line between the two pieces.

    Hope that helps. Give us some more details, and someone here can probably give you a better answer.

    Erik


  • Simple Toobar question ? perhaps not....