SplitContainer

G

Guest

In products like the new version of Outlook the splitter bars contain a
series of 'dots' in the middle to indicate and highlight the splitter bar. I
see this is not available using the SplitContainer control in Visual Studio.

Is it possible to draw these 'dots' on the splitter bar? I have tried
numerous methods but cannot get it to work. Any help much appreciated.

Cheers.
 
O

Oliver Sturm

Hello Steve,
Is it possible to draw these 'dots' on the splitter bar? I have tried
numerous methods but cannot get it to work. Any help much appreciated.

I don't think it can easily be done with the standard splitter control. Of
course you could create your own and do what you want... :)


Oliver Sturm
 
C

ClayB

One thing you can try is to derive the Splitter class and override
OnPaint. There you can draw whatever you want to draw.

public class MySplitter : Splitter
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = this.ClientRectangle;
rect.Y = rect.Y + rect.Height / 2 - 4;
rect.Height = 8;
e.Graphics.FillRectangle(Brushes.Pink, rect);
}
}
=======================
Clay Burch
Syncfusion, Inc.
 
O

Oliver Sturm

Hello ClayB,
One thing you can try is to derive the Splitter class and override
OnPaint. There you can draw whatever you want to draw.

True of course, maybe I should have had a closer look - but even though my
post mentioned the "splitter control", we were really talking about the
SplitContainer, and I believe this control doesn't allow easy access to
the relevant paint events. If I'm wrong - sorry for not looking into more
detail at this time.


Oliver Sturm
 
O

Oliver Sturm

Hello Steve,
In products like the new version of Outlook the splitter bars contain a
series of 'dots' in the middle to indicate and highlight the splitter bar.
I
see this is not available using the SplitContainer control in Visual
Studio.

Is it possible to draw these 'dots' on the splitter bar? I have tried
numerous methods but cannot get it to work. Any help much appreciated.

So, after a bit of a discussion in this thread, I had a closer look at
things. To my surprise I found that it's really easy to do this - I was
confused by some previous experience that obviously wasn't really related
to this issue and by the fact that you say you tried numerous methods
without success. So here's how you can do it:

* Drop a SplitContainer on a form

* Set the SplitterWidth property on the container to 10, this will make things easier to see.

* Create an event handler for the Paint event of the container. Careful: you want the event handler for the container, not that for any one of the two panels inside it. Make sure to select the complete container before you add the handler.

* Add the following code to the event handler:

Rectangle rect = splitContainer1.SplitterRectangle;
int middleY = rect.Y + rect.Height / 2;
int middleX = rect.X + rect.Width / 2;

e.Graphics.DrawLine(Pens.Red,
middleX, middleY - 5, middleX, middleY + 5);

Of course this is an extremely simple example - it simply draws a line in
the middle of the splitter area, it makes sense only with vertical
splitters and so on. You'll have to make it more flexible for your purposes.

Now, I was going to implement some "dot drawing" like you say Outlook
does, but looking at my Outlook (2007) I don't see any such dots on any
splitters. I thought I knew what you meant because I've seen similar
splitter visualization in other apps in the past, but Outlook doesn't seem
to do it - maybe it's because I'm running on Vista, where the drawing may
be slightly different to other Windows versions.


Oliver Sturm
 

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