By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,723 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,723 IT Pros & Developers. It's quick & easy.

Center an image on a tab page

P: n/a
Hi,

I have a tab control containing few tab pages. On each tab
pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).

If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the
text, the image will position itself more to the left and
it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies

P: n/a
Sean,

There is a way to center the image. you have to add Paint Event of tab page
and get the graphics pointer

Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw, TestImageWidth,
TestImageHeight));

xDraw, and yDraw will get you the offset to center the image.

Shak.
"Sean" <an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl...
Hi,

I have a tab control containing few tab pages. On each tab
pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).

If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the
text, the image will position itself more to the left and
it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean

Nov 16 '05 #2

P: n/a
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains
the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

-----Original Message-----
Sean,

There is a way to center the image. you have to add Paint Event of tab pageand get the graphics pointer

Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw, TestImageWidth,TestImageHeight));

xDraw, and yDraw will get you the offset to center the image.
Shak.
"Sean" <an*******@discussions.microsoft.com> wrote in messagenews:1d*****************************@phx.gbl...
Hi,

I have a tab control containing few tab pages. On each tab pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).
If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the text, the image will position itself more to the left and it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean

.

Nov 16 '05 #3

P: n/a
Ok...

Instead of adding paint event in tabpage, do the following

1.Set DrawMode Property of TabControl to OwnerDrawnFixed
2.add DrawItem event of Tabcontrol.
3. Get the graphics pointer and center the image.

Shak.
<an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl...
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains
the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

-----Original Message-----
Sean,

There is a way to center the image. you have to add Paint

Event of tab page
and get the graphics pointer

Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw,

TestImageWidth,
TestImageHeight));

xDraw, and yDraw will get you the offset to center the

image.

Shak.
"Sean" <an*******@discussions.microsoft.com> wrote in

message
news:1d*****************************@phx.gbl...
Hi,

I have a tab control containing few tab pages. On each tab pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).
If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the text, the image will position itself more to the left and it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean

.

Nov 16 '05 #4

P: n/a
Hi Shak,

Thank you so much for your last post.
It works! However, there is a white line between the title
bar and the tabpage even for the selectedPage. This line
wasn't there when I had the DrawMode as Normal.

Is there a way to get rid of the white line between the
title bar and the tabpage for the selectedPage?

Thank you once again.
regards,
Sean
-----Original Message-----
Ok...

Instead of adding paint event in tabpage, do the following

1.Set DrawMode Property of TabControl to OwnerDrawnFixed
2.add DrawItem event of Tabcontrol.
3. Get the graphics pointer and center the image.

Shak.
<an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl...
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

>-----Original Message-----
>Sean,
>
>There is a way to center the image. you have to add Paint
Event of tab page
>and get the graphics pointer
>
>Graphics g = e.Graphics.
>g.DrawImage(TestImage, new Rectangle(xDraw, yDraw,

TestImageWidth,
>TestImageHeight));
>
>xDraw, and yDraw will get you the offset to center the

image.
>
>Shak.
>
>
>"Sean" <an*******@discussions.microsoft.com> wrote in

message
>news:1d*****************************@phx.gbl...
>
>> Hi,
>>
>> I have a tab control containing few tab pages. On
each tab
>> pages, I put an image on the tab page's title bar

(the >> area on top of a tab page, ie where tooltip will

appear).
>>
>> If i put both an image and a text, they both will be
>> centered nicely. However, if I put only image without

the
>> text, the image will position itself more to the left

and
>> it is not centered.
>>
>> Is it possible to have the image to be on the center?
>> Thank you.
>>
>>
>> regards,
>> Sean
>
>
>.
>

.

Nov 16 '05 #5

P: n/a
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains
the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

-----Original Message-----
Sean,

There is a way to center the image. you have to add Paint Event of tab pageand get the graphics pointer

Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw, TestImageWidth,TestImageHeight));

xDraw, and yDraw will get you the offset to center the image.
Shak.
"Sean" <an*******@discussions.microsoft.com> wrote in messagenews:1d*****************************@phx.gbl...
Hi,

I have a tab control containing few tab pages. On each tab pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).
If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the text, the image will position itself more to the left and it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean

.

Nov 16 '05 #6

P: n/a
Ok...

Instead of adding paint event in tabpage, do the following

1.Set DrawMode Property of TabControl to OwnerDrawnFixed
2.add DrawItem event of Tabcontrol.
3. Get the graphics pointer and center the image.

Shak.
<an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl...
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains
the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

-----Original Message-----
Sean,

There is a way to center the image. you have to add Paint

Event of tab page
and get the graphics pointer

Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw,

TestImageWidth,
TestImageHeight));

xDraw, and yDraw will get you the offset to center the

image.

Shak.
"Sean" <an*******@discussions.microsoft.com> wrote in

message
news:1d*****************************@phx.gbl...
Hi,

I have a tab control containing few tab pages. On each tab pages, I put an image on the tab page's title bar (the
area on top of a tab page, ie where tooltip will appear).
If i put both an image and a text, they both will be
centered nicely. However, if I put only image without the text, the image will position itself more to the left and it is not centered.

Is it possible to have the image to be on the center?
Thank you.
regards,
Sean

.

Nov 16 '05 #7

P: n/a
Hi Shak,

Thank you so much for your last post.
It works! However, there is a white line between the title
bar and the tabpage even for the selectedPage. This line
wasn't there when I had the DrawMode as Normal.

Is there a way to get rid of the white line between the
title bar and the tabpage for the selectedPage?

Thank you once again.
regards,
Sean
-----Original Message-----
Ok...

Instead of adding paint event in tabpage, do the following

1.Set DrawMode Property of TabControl to OwnerDrawnFixed
2.add DrawItem event of Tabcontrol.
3. Get the graphics pointer and center the image.

Shak.
<an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl...
Hi Shak,

Thank you for your reply.

It worked. Unfortunately, the yDraw actually starts from
the tabpage, but not the square area that usually contains the text/title for the tabpage.

I want the image to be centered on the square where the
title/text shown.

Thank you.
regards,
Sean

>-----Original Message-----
>Sean,
>
>There is a way to center the image. you have to add Paint
Event of tab page
>and get the graphics pointer
>
>Graphics g = e.Graphics.
>g.DrawImage(TestImage, new Rectangle(xDraw, yDraw,

TestImageWidth,
>TestImageHeight));
>
>xDraw, and yDraw will get you the offset to center the

image.
>
>Shak.
>
>
>"Sean" <an*******@discussions.microsoft.com> wrote in

message
>news:1d*****************************@phx.gbl...
>
>> Hi,
>>
>> I have a tab control containing few tab pages. On
each tab
>> pages, I put an image on the tab page's title bar

(the >> area on top of a tab page, ie where tooltip will

appear).
>>
>> If i put both an image and a text, they both will be
>> centered nicely. However, if I put only image without

the
>> text, the image will position itself more to the left

and
>> it is not centered.
>>
>> Is it possible to have the image to be on the center?
>> Thank you.
>>
>>
>> regards,
>> Sean
>
>
>.
>

.

Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.