|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article presents an extension of the .NET DesignCustom drop-down functionality can be achieved using the .NET In addition to facilitating this control, the Previously the drop-down control was resizable by nesting a resizable container. This was an okay solution (because it worked) but it caused some redraw errors during resize operations. The resize functionality has now been significantly improved, and it is now also possible to define which sides of the drop-down are resizable (if any). Resizing can now also be done by dragging the resizable edges of the drop-down. The new resize functionality is achieved by intercepting Win32 hit testing messages, and responding appropriately based upon the set The following UML class diagram provides an overview of the presented classes:
Using the CodeAs with most controls, this control can be created dynamically at runtime, or by using the Visual C# IDE designer's drag and drop features. During runtime, the property Most drop-down controls appear better when their borders are removed. namespace CustomComboDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Dynamically created controls.
// Create grid view control.
DataGridView gridView = new DataGridView();
gridView.BorderStyle = BorderStyle.None;
gridView.Columns.Add("Column1", "Column 1");
gridView.Columns.Add("Column2", "Column 2");
gridView.Columns.Add("Column3", "Column 3");
gridView.Columns.Add("Column4", "Column 4");
gridView.Columns.Add("Column5", "Column 5");
this.customComboBox1.DropDownControl = gridView;
// Create user control.
UserControl1 userControl = new UserControl1();
userControl.BorderStyle = BorderStyle.None;
this.customComboBox2.DropDownControl = userControl;
// Create rich textbox control.
RichTextBox richTextBox = new RichTextBox();
richTextBox.BorderStyle = BorderStyle.None;
this.customComboBox3.DropDownControl = richTextBox;
}
}
}
Points of InterestWhen writing the code I found that dropped-down controls were not retrieving immediate input focus. This problem occurs because even though the drop-down code is ignored during the Win32 message handler, the standard win32 drop-down still appears (1x1 pixels). To avoid this, a timer is created which forces the dropped-down control to be focused after the default win32 drop-down has been focused. Once the timer has done its job, it disables itself. History
|
||||||||||||||||||||||