1

I'm attempting to write a custom button user control. I have run into a challenge when drawing the image.

Is there a simple way to draw the image accounting for the ImageAlign and TextImageRelation? (Kind of like StringFormat makes text aligning a breeze)

Or do I have to do all the aligning logic and stuff manually?

Thanks

1
  • Is this an ASP.Net button user control or a winforms button or some other type of button out there? Commented Mar 30, 2009 at 20:22

2 Answers 2

1

What functionality are you trying to achieve? Perhaps it should instead inherit from the Button class (asssuming WinForms), and override appropiate methods. Depending on what you need to do, you will propably get much of the lower levels of functionality in the button for free, if you do this.

To get back to your question; No, if you need to draw stuff yourself, there is no magic easy way to determine where the individual pixels should go :-) One great helper in doing this, that you should be aware of, is the Graphics.DrawString method. It lets you measure the dimensions of a given text string when drawn on the control with the selected font and size.

Sign up to request clarification or add additional context in comments.

Comments

0

I do not know of anything that does this stuff for you, but be aware of the ControlPaint class as that has a bunch of handy utility methods for painting controls.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.