G
Guest
This question concerns something I'm trying to do with the CF but it's really
a generic C# question.
With the Compact Framework, one can't add a radio button with a long label
because the labels don't wrap. So I've decided to create my own custom radio
button. With my version there will be a basic radio button with no text and
its size reduced to 12 x 12. Then beside this I will place a LinkLabel,
which will wrap, to give the appearance of a multi-line label.
Here's the basic code I've written so far:
public class RadioButtonEx : RadioButton
{
LinkLabel linkLabel = new LinkLabel();
public RadioButtonEx()
{
base.Width = 12;
base.Height = 12;
linkLabel.Click += new EventHandler(linkLabel_Click);
}
private string text;
public override string Text
{
get
{
return text;
}
set
{
text = value;
linkLabel.Text = value;
if (this.Parent != null)
{
if (! this.Parent.Controls.Contains(linkLabel))
{
this.Parent.Controls.Add(linkLabel);
linkLabel.Location = new Point(this.Right + 6, this.Top);
}
}
}
}
private string width;
public override int Width
{
get
{
return width;
}
set
{
linkLabel.Width = value - 18;
}
}
private string height;
public override int Height
{
get
{
return height;
}
set
{
linkLabel.Height = value;
}
}
private void linkLabel_Click(object sender, EventArgs e)
{
this.Checked = true; // If the label is clicked then check the radio
button
}
}
But I'm getting this sort of error about the gets and sets of the Width &
Height:
Cannot override inherited member 'System.Windows.Forms.Control.Width.set'
because it is not marked virtual, abstract, or override
How do I resolve this?
a generic C# question.
With the Compact Framework, one can't add a radio button with a long label
because the labels don't wrap. So I've decided to create my own custom radio
button. With my version there will be a basic radio button with no text and
its size reduced to 12 x 12. Then beside this I will place a LinkLabel,
which will wrap, to give the appearance of a multi-line label.
Here's the basic code I've written so far:
public class RadioButtonEx : RadioButton
{
LinkLabel linkLabel = new LinkLabel();
public RadioButtonEx()
{
base.Width = 12;
base.Height = 12;
linkLabel.Click += new EventHandler(linkLabel_Click);
}
private string text;
public override string Text
{
get
{
return text;
}
set
{
text = value;
linkLabel.Text = value;
if (this.Parent != null)
{
if (! this.Parent.Controls.Contains(linkLabel))
{
this.Parent.Controls.Add(linkLabel);
linkLabel.Location = new Point(this.Right + 6, this.Top);
}
}
}
}
private string width;
public override int Width
{
get
{
return width;
}
set
{
linkLabel.Width = value - 18;
}
}
private string height;
public override int Height
{
get
{
return height;
}
set
{
linkLabel.Height = value;
}
}
private void linkLabel_Click(object sender, EventArgs e)
{
this.Checked = true; // If the label is clicked then check the radio
button
}
}
But I'm getting this sort of error about the gets and sets of the Width &
Height:
Cannot override inherited member 'System.Windows.Forms.Control.Width.set'
because it is not marked virtual, abstract, or override
How do I resolve this?