Click here to Skip to main content
15,927,060 members
Home / Discussions / C#
   

C#

 
GeneralRe: avoiding double invoking Pin
Stephan Wright10-Aug-04 23:45
Stephan Wright10-Aug-04 23:45 
GeneralRe: avoiding double invoking Pin
Stephan Wright11-Aug-04 7:53
Stephan Wright11-Aug-04 7:53 
GeneralRe: avoiding double invoking Pin
Nick Parker11-Aug-04 9:13
protectorNick Parker11-Aug-04 9:13 
GeneralRe: avoiding double invoking Pin
Stephan Wright11-Aug-04 20:59
Stephan Wright11-Aug-04 20:59 
GeneralRe: avoiding double invoking Pin
Anonymous12-Aug-04 2:05
Anonymous12-Aug-04 2:05 
Generalinstall AddIn in VS.NET2003 Pin
nthevu10-Aug-04 3:08
professionalnthevu10-Aug-04 3:08 
GeneralRe: install AddIn in VS.NET2003 Pin
Nick Parker10-Aug-04 3:56
protectorNick Parker10-Aug-04 3:56 
QuestionHow to change default color of Tabpage >> Answer Pin
sreejith ss nair10-Aug-04 2:57
sreejith ss nair10-Aug-04 2:57 
hi,
Actually i posted one queary that " How we will change the color(caption color) of a Tabpage". Unfortunately i forgot to post the answer here. So Here is the answer for " How we will change the color(caption color) of a Tabpage.

Who is going to draw ?

Tabcontrol have a properties called DrawMode. This will set or get the value that whether user or system will paint the caption.By default it is normal. Means system(OS) will paint the caption for you. If you(parent form) want to draw the caption you have to set the value of the property to OwnerDrawFixed.

You can mention DrawMode on design time or runtime like below mentioned code.

this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;

Now you mention who is going to draw the caption.


Next thing is how is going draw ?

Tab control have an event called DrawItem event which will occure when ever an area need to be painted.

eg:

this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem);



private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{


Font f;
Brush backBrush;
Brush foreBrush;

if(e.Index == this.tabControl1.SelectedIndex)
{
f = new Font(e.Font, FontStyle.Bold | FontStyle.Bold);
backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Blue, Color.Gold, System.Drawing.Drawing2D.LinearGradientMode.Vertical);

foreBrush = Brushes.White;
}

else
{
f = e.Font;
backBrush = new SolidBrush(e.BackColor);
foreBrush = new SolidBrush(e.ForeColor);
}

string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
e.Graphics.FillRectangle(backBrush, e.Bounds);
Rectangle r = e.Bounds;
r = new Rectangle(r.X, r.Y + 3, r.Width, r.Height - 3);
e.Graphics.DrawString(tabName, f, foreBrush, r, sf);
sf.Dispose();
if(e.Index == this.tabControl1.SelectedIndex)
{
f.Dispose();
backBrush.Dispose();
}
else
{
backBrush.Dispose();
foreBrush.Dispose();
}
}
}

Sory for this late posting Wink | ;) Blush | :O

**************************
S r e e j i t h N a i r
**************************
AnswerRe: How to change default color of Tabpage >> Answer Pin
Nick Parker10-Aug-04 4:00
protectorNick Parker10-Aug-04 4:00 
GeneralRe: How to change default color of Tabpage >> Answer Pin
sreejith ss nair10-Aug-04 17:11
sreejith ss nair10-Aug-04 17:11 
GeneralTitle bar Height Pin
Shiva_Hosa10-Aug-04 1:56
Shiva_Hosa10-Aug-04 1:56 
GeneralSetting a policy using c# Pin
Freddie8310-Aug-04 1:44
Freddie8310-Aug-04 1:44 
GeneralRe: Setting a policy using c# Pin
Heath Stewart10-Aug-04 6:43
protectorHeath Stewart10-Aug-04 6:43 
GeneralRe: Setting a policy using c# Pin
Freddie8311-Aug-04 0:51
Freddie8311-Aug-04 0:51 
GeneralRe: Setting a policy using c# Pin
Heath Stewart11-Aug-04 2:28
protectorHeath Stewart11-Aug-04 2:28 
GeneralRe: Setting a policy using c# Pin
Freddie8311-Aug-04 2:50
Freddie8311-Aug-04 2:50 
GeneralRe: Setting a policy using c# Pin
Freddie8312-Aug-04 5:50
Freddie8312-Aug-04 5:50 
GeneralAdding item in start menu and .... Pin
ting66810-Aug-04 0:19
ting66810-Aug-04 0:19 
GeneralRe: Adding item in start menu and .... Pin
Heath Stewart10-Aug-04 6:41
protectorHeath Stewart10-Aug-04 6:41 
GeneralGet RichTextBox's content as Image Pin
bobikov_aj10-Aug-04 0:04
bobikov_aj10-Aug-04 0:04 
GeneralRe: Get RichTextBox's content as Image Pin
Heath Stewart10-Aug-04 6:38
protectorHeath Stewart10-Aug-04 6:38 
Generalregister C# window Pin
ting6689-Aug-04 22:45
ting6689-Aug-04 22:45 
GeneralRe: register C# window Pin
Nick Parker10-Aug-04 3:40
protectorNick Parker10-Aug-04 3:40 
GeneralRe: register C# window Pin
ting66810-Aug-04 15:41
ting66810-Aug-04 15:41 
Generalcheck if minimizebutton was clicked Pin
Stephan Wright9-Aug-04 22:16
Stephan Wright9-Aug-04 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.