Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Tab and menustrip controls
 

Tab and menustrip controls

Hello Smile

I'm fairly new to vb.

I have added a few tab controls to my program, but the background of the form is black, as is the background of the tabs. This makes it have a thick border around it which doesn't look nice on a black background Sad

Is there any way to remove this? I have searched for hours and have read somewhere that it may be possible with a user drawn form. Not only do i not know how to do that, but I don't want to lose the hover effects you get in vista.

Another question i have about tab controls is about multiline tab control. I have two lines of tabs, but when you click on a tab, it brings it to the bottom. This is very annoying so i was wondering if there is a way to get them to stay in static positions when you click them Smile

Finally, I have added a menustrip, which has a black background to go thing my forms background. This meant i have to have a light colour text to show up. However, when the program is running, if you hover over these, the hover effect from vista makes the text very hard to read. The same happens with the text in the menus of the menu bar. Is there a simple way to solve this one?

Thank you in advance for your help Smile
sam_8999  Thursday, July 31, 2008 7:53 AM

Hi Sam_8999,

How’s your progress?

Generally speaking, all these three functions would run better if we use OnwerDraw. After some time of researching, though not all requirements are achieved, I’ll give you the solution as well as I can.

sam_8999 wrote:

Is there any way to remove this? I have searched for hours and have read somewhere that it may be possible with a user drawn form. Not only do i not know how to do that, but I don't want to lose the hover effects you get in vista.

To answer the first question, I have work the hove effect out by writing Mouse.Hove event, and it works fine, you can add other owner draw code into DrawItem event and make other effect to work. Please refer to the following code about hove effect:

Code Snippet

private void tabControl1_MouseMove(object sender, MouseEventArgs e)

for (int i = 0; i < this.tabControl1.TabPages.Count; i++)

using (Graphics g = this.tabControl1.CreateGraphics())

Rectangle hoveRec = this.tabControl1.GetTabRect(i);

if (this.tabControl1.GetTabRect(i).Contains(this.tabControl1.PointToClient(Cursor.Position)) && i != this.tabControl1.SelectedIndex)

new SolidBrush(Color.Red), hoveRec);

this.tabControl1.TabPages[i].Text, new Font("Arial", 8), new SolidBrush(Color.Black), new PointF(hoveRec.X + 2, hoveRec.Y + 2));

else

new SolidBrush(Color.LightGray), hoveRec);

this.tabControl1.TabPages[i].Text, new Font("Arial", 8), new SolidBrush(Color.Black), new PointF(hoveRec.X + 2, hoveRec.Y + 2));

sam_8999 wrote:

Another question i have about tab controls is about multiline tab control. I have two lines of tabs, but when you click on a tab, it brings it to the bottom. This is very annoying so i was wondering if there is a way to get them to stay in static positions when you click them

For the second question, I’m afraid that I cannot find a effective way to stop tabs from altering lines. Hope that someone else can help you.


sam_8999 wrote:

Finally, I have added a menustrip, which has a black background to go thing my forms background. This meant i have to have a light colour text to show up. However, when the program is running, if you hover over these, the hover effect from vista makes the text very hard to read. The same happens with the text in the menus of the menu bar. Is there a simple way to solve this one?

For the last question, I have tested many colors, and found that colors which are close to Red can display well under this Black condition. Of course you can find other colors as you like. I believe that it’s a work of finding a proper color rather than coding.

For your information, here are some good examples for custom draw TabControl, I believe that they can help:

A .NET Flat TabControl (CustomDraw)

How to Change the colours of a Tabcontrols Header Item

That’s all I can help.

However, if there isfurther question, please feel free to let me know. See if I can help.

Thanks.

Best wishes,

Jun Wang

Jun Wang Tim  Wednesday, August 06, 2008 9:10 AM

Hi Sam_8999,

How’s your progress?

Generally speaking, all these three functions would run better if we use OnwerDraw. After some time of researching, though not all requirements are achieved, I’ll give you the solution as well as I can.

sam_8999 wrote:

Is there any way to remove this? I have searched for hours and have read somewhere that it may be possible with a user drawn form. Not only do i not know how to do that, but I don't want to lose the hover effects you get in vista.

To answer the first question, I have work the hove effect out by writing Mouse.Hove event, and it works fine, you can add other owner draw code into DrawItem event and make other effect to work. Please refer to the following code about hove effect:

Code Snippet

private void tabControl1_MouseMove(object sender, MouseEventArgs e)

for (int i = 0; i < this.tabControl1.TabPages.Count; i++)

using (Graphics g = this.tabControl1.CreateGraphics())

Rectangle hoveRec = this.tabControl1.GetTabRect(i);

if (this.tabControl1.GetTabRect(i).Contains(this.tabControl1.PointToClient(Cursor.Position)) && i != this.tabControl1.SelectedIndex)

new SolidBrush(Color.Red), hoveRec);

this.tabControl1.TabPages[i].Text, new Font("Arial", 8), new SolidBrush(Color.Black), new PointF(hoveRec.X + 2, hoveRec.Y + 2));

else

new SolidBrush(Color.LightGray), hoveRec);

this.tabControl1.TabPages[i].Text, new Font("Arial", 8), new SolidBrush(Color.Black), new PointF(hoveRec.X + 2, hoveRec.Y + 2));

sam_8999 wrote:

Another question i have about tab controls is about multiline tab control. I have two lines of tabs, but when you click on a tab, it brings it to the bottom. This is very annoying so i was wondering if there is a way to get them to stay in static positions when you click them

For the second question, I’m afraid that I cannot find a effective way to stop tabs from altering lines. Hope that someone else can help you.


sam_8999 wrote:

Finally, I have added a menustrip, which has a black background to go thing my forms background. This meant i have to have a light colour text to show up. However, when the program is running, if you hover over these, the hover effect from vista makes the text very hard to read. The same happens with the text in the menus of the menu bar. Is there a simple way to solve this one?

For the last question, I have tested many colors, and found that colors which are close to Red can display well under this Black condition. Of course you can find other colors as you like. I believe that it’s a work of finding a proper color rather than coding.

For your information, here are some good examples for custom draw TabControl, I believe that they can help:

A .NET Flat TabControl (CustomDraw)

How to Change the colours of a Tabcontrols Header Item

That’s all I can help.

However, if there isfurther question, please feel free to let me know. See if I can help.

Thanks.

Best wishes,

Jun Wang

Jun Wang Tim  Wednesday, August 06, 2008 9:10 AM
Hello, thanks a lot for your reply Smile I'm now going to try the things you said. I also found a custom menu strip item from one of the links you gave me which should do what i want.
sam_8999  Wednesday, August 06, 2008 2:35 PM

You can use google to search for other answers

Custom Search

More Threads

• Adding EDIT function to DATAGRID Rows• Treeview - Problem with multiple languages• error "Object type cannot be converted to target type." in task list• Custom serialization of extender properties• Microsoft Visual studio has encountered a problem and needs to close• Designer auto assigning bogus string resource values• VB.NET 2003 + Sourabh Das• Design Time Controls Macros• BUG - Controls disapear• A Generic error ocured on GDI+ on windows Vista