Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2007, 10:01 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default customize button

hi expert
i created a classLibrary that inherited from Button
i Override the Onpaint event for this button to create a gradiant rectangle for this button

my code is



Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ClassLibrary1
{
    public class Class1 :Button
    {

        public Class1()
        {

            this.Size = new Size(100, 20);
            this.Location = new Point(0, 0);
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            pevent.Graphics.Clear(this.Parent.BackColor);
            Rectangle rect = new Rectangle(new Point(this.Location.X, this.Location.Y), new Size(this.Width, this.Height));
            LinearGradientBrush lgrad = new LinearGradientBrush(rect, Color.Red, Color.Blue, LinearGradientMode.BackwardDiagonal);

            pevent.Graphics.FillRectangle(lgrad, rect);

            lgrad.Dispose();
        }
           
    }
}

i have 2 problem
first my text on the button isn't show !!
and last when my button is at location (0,0) my gradiant shows successfully but when the location was changed my gradiant rectangle shows unormally

i upload my program at flowing location
please see that and ghelp me
regards

link :


http://www.esnips.com/doc/e074814e-9...ustomizeButton





Similar Threads
Thread Thread Starter Forum Replies Last Post
Customize Datagrid Mohamed_sherief ASP.NET 2.0 Professional 5 August 23rd, 2007 09:31 PM
customize Paula222 ASP.NET 2.0 Professional 0 November 9th, 2006 12:19 AM
customize menu Paula222 ASP.NET 2.0 Basics 0 November 9th, 2006 12:19 AM
Customize Search Results bmains ASP.NET 1.0 and 1.1 Professional 4 January 15th, 2004 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.