|
From: Zhi-xin Ye on 1 Jul 2008 09:46 Dear Oriane, Based on my understanding, you assign an image to a button by setting the Image property of the button, but you want the image to fit the size of the button, similar to a "stretch" layout. If I misunderstand you, please let me know. As far as I know, there is no direct way like "ImageLayout" there to set layout for the button image. In order to accomplish it, we could use the following ways: 1. Use the BackgroundImage property instead. Then we can change the image layout by setting the BackgroundImageLayout property. For more information about the BackgroundImage property, you can read this document: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.backgro undimage.aspx 2. Handle the Button.Paint event to draw the button image at right location. The following sample demonstrates how to draw the button image to make it show up in a "stretch" layout style. void button1_Paint(object sender, PaintEventArgs e) { Rectangle rect = e.ClipRectangle; // Adjust the rectangle for drawing the button image rect.X += 4; rect.Y += 4; rect.Width -= 8; rect.Height -= 8; e.Graphics.DrawImage(this.button1.Image, rect); using (SolidBrush br = new SolidBrush(this.button1.ForeColor)) { StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(this.button1.Text, this.button1.Font, br, e.ClipRectangle, sf); } } 3. Create a copy of the image with the right size to fit in the button, and assign this copy to the button Image property instead. For how to create a copy of an image with a different size, you can read this document: How to: Create a Zoom Effect http://msdn.microsoft.com/en-us/library/ms229648(VS.80).aspx I hope these alternatives make sense to you. If you need further help on this, please don't hesitate to let me know. Best Regards, Zhi-Xin Ye Microsoft Newsgroup Support Team Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg(a)microsoft.com. ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
From: Oriane on 2 Jul 2008 04:35 Hello, "Zhi-xin Ye" <v-zhye(a)online.microsoft.com> a �crit dans le message de news:div%23hD42IHA.5336(a)TK2MSFTNGHUB02.phx.gbl... > Dear Oriane, > > Based on my understanding, you assign an image to a button by setting the > Image property of the button, but you want the image to fit the size of > the > button, similar to a "stretch" layout. > > If I misunderstand you, please let me know. Your understanding is correct > As far as I know, there is no direct way like "ImageLayout" there to set > layout for the button image. > > In order to accomplish it, we could use the following ways: > > 1. Use the BackgroundImage property instead. Fine. I take this option ! Thanks a lot
From: Zhi-xin Ye on 3 Jul 2008 06:41 Dear Oriane, You're welcome! If you have any other questions in the future, please don't hesitate to contact us. It's always our pleasure to be of help! Have a good day! Sincerely, Zhi-Xin Ye Microsoft Newsgroup Support Team Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg(a)microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.
|
Pages: 1 Prev: Assembly policy for non-GAC dlls Next: LINQ Editor suggestions |