Hi All,
Just been toying around with inheriting from the ComboBox control. See below
a simple example of the new ComboBox class.
// start MyComboBox.cs file
using System;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
namespace MyComboBox.UI
{
/// <summary>
/// Summary description for MyComboBox.
/// </summary>
public class MyComboBox : ComboBox
{
public MyComboBox()
{
this.ForeColor = Color.DarkBlue;
}
protected override void OnHandleCreated(EventArgs e)
{
if (this.DesignMode)
{
this.Items.Add("Design Mode");
}
else
{
this.Items.Add("Run-time Mode");
}
this.Items.Add("Orange");
this.Items.Add("Apple");
this.Items.Add("Pie");
}
}
}
// end
There's no problem adding the control to my toolbox. Also - no problem
dragging and dropping the custom combo onto the design canvas.
Strange thing is, after switching between design time and code a couple of
times and running it - the font seems to change into a bigger font,
something like Arial bold or such.
Also, I suppose I need to specify some attribute tags before the class
definition. Any ideas or suggestions?
Thanks a bunch,
Wim Hollebrandse