 |
|
|
|
| Author |
Message |
cameljs18
Joined: 13 Dec 2007 Posts: 1
|
Posted: Thu Dec 13, 2007 10:37 am Post subject: displaying inherited button |
|
|
Should be easy don't know y i cant get it to work please help.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class mybutton : Button
{
}
}
I also need to find out how to override the properties to create a
different shape eg. a round button.Thanks
Archived from group: microsoft>public>dotnet>languages>csharp |
|
| Back to top |
|
 |
Nicholas Paldino [.NET/C#
Joined: 08 Aug 2007 Posts: 71
|
Posted: Thu Dec 13, 2007 3:02 pm Post subject: Re: displaying inherited button |
|
|
Well, you should probably declare the button somewhere outside of your
Form1 class, unless the myButton class is tied specifically to Form1.
Also, you will need to override the OnPaint method to change the
appearance of the button.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
wrote in message @s19g2000prg.googlegroups.com...
> Should be easy don't know y i cant get it to work please help.
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
>
> }
>
>
> public class mybutton : Button
> {
>
> }
> }
> I also need to find out how to override the properties to create a
> different shape eg. a round button.Thanks |
|
| Back to top |
|
 |
DSK Chakravarthy
Joined: 08 Aug 2007 Posts: 2
|
Posted: Fri Dec 14, 2007 1:31 am Post subject: Re: displaying inherited button |
|
|
When you look at the system defined controls like Button, they have
predefined sizes inherited from System.Drawing.Size. This Point has only 3
overloads such as
1) Default - resulting 0 width and 0 length
2) System.Drawing.Point( oneInputParameter) - resulting width = length =
oneInputParameter
3) Width and length - both as the different input parameters
So, by looking at the above information, I doubt you can over ride the shape
information.
But apart of that, you still can do the intention behind having a separate
shape.
Step 1) First create an ENum of all shapes
Step 2) Create a property for the derived button as "DifferentShape"
Step 3) At the property try to change the shape of the button with a kind of
image on the button at runtime, with the help of System.Drawing dynamically
HTH
Chakravarthy
wrote in message @s19g2000prg.googlegroups.com...
> Should be easy don't know y i cant get it to work please help.
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
>
> }
>
>
> public class mybutton : Button
> {
>
> }
> }
> I also need to find out how to override the properties to create a
> different shape eg. a round button.Thanks |
|
| Back to top |
|
 |
Peter Duniho
Joined: 08 Aug 2007 Posts: 45
|
Posted: Thu Dec 13, 2007 2:59 pm Post subject: Re: displaying inherited button |
|
|
On Thu, 13 Dec 2007 07:02:21 -0800, Nicholas Paldino [.NET/C# MVP]
wrote:
> Well, you should probably declare the button somewhere outside of
> your Form1 class, unless the myButton class is tied specifically to
> Form1.
>
> Also, you will need to override the OnPaint method to change the
> appearance of the button.
Keeping mind that if the Button control is like many of the other Forms
controls, overriding OnPaint() doesn't actually prevent the original
Button drawing from happening, because the control doesn't actually use
OnPaint() for its drawing.
I don't actually know specifically whether the Button control is one of
those, but many Forms controls require a lot more work to override their
default drawing behavior than just overriding OnPaint(). It's certainly
worth a try, but it may be more complicated than that.
Pete |
|
| Back to top |
|
 |
Nicholas Paldino [.NET/C#
Joined: 08 Aug 2007 Posts: 71
|
Posted: Thu Dec 13, 2007 7:40 pm Post subject: Re: displaying inherited button |
|
|
I agree. Specifically, the OP will have to override the WndProc method
and handle the WM_PAINT message, and not call the base implementation if
they want to paint the button themselves.
You can override OnPaint if what needs to be painted paints over the
existing graphics.
Honestly, though, Windows Forms/GDI just doesn't support this scenario
well. WPF, however, handles it very well.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Peter Duniho" wrote in message @petes-computer.local...
> On Thu, 13 Dec 2007 07:02:21 -0800, Nicholas Paldino [.NET/C# MVP]
> wrote:
>
>> Well, you should probably declare the button somewhere outside of
>> your Form1 class, unless the myButton class is tied specifically to
>> Form1.
>>
>> Also, you will need to override the OnPaint method to change the
>> appearance of the button.
>
> Keeping mind that if the Button control is like many of the other Forms
> controls, overriding OnPaint() doesn't actually prevent the original
> Button drawing from happening, because the control doesn't actually use
> OnPaint() for its drawing.
>
> I don't actually know specifically whether the Button control is one of
> those, but many Forms controls require a lot more work to override their
> default drawing behavior than just overriding OnPaint(). It's certainly
> worth a try, but it may be more complicated than that.
>
> Pete
|
|
| Back to top |
|
 |
|
|
| Related Topics: | How do I set DesignerSerializationVisibility on inherited pr Hi, I've created a control which inherits from the ListView class. In the constructor I create 2 columns and add a two items to propulate a row. This is all ok, when I use the control at design time my constructor is called and I see the columns and data
Inherited Windows Form Hi All, I am trying to inherit from a base windows form. However, when i try to view the inherited form in design time, it gives me the following error at first "Specified cast is not valid." Then I go back to the inherited for class and just type a white
How do I add an Inherited Control to my ToolBox Hi, I have created my own derived control that inherits from a TextBox. How do I make this control appear in the ToolBox? Cheers Andrew
Inherited form, Moving of controls Hello, I have a parent form with one tab control on it and a text box in that tab control. I would like to Move that text box off of the page it is currently on in the child form. The tab control and the text box are both marked as protected ( I have a
Strange behaviour with inherited forms (BUG?) Hello, I experienced a strange behaviour with the forms designer and inherited forms. This is the situation: There is a solution containing a "Class Library" and "Windows Application". Inside the class library there is a "base" form with a TabControl and |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|