HorizontallyScrollingComboBox/MainForm.cs
Download
horizontallyscrollingcombobox.zip
(11.88 KB | 13 July 2010 )
Sample C# project showing how to add a horizontal scrollbar to a ComboBox in C# using the WS_HSCROLL style and CB_SETHORIZONTALEXTENT message.
Donate
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Contents of horizontallyscrollingcombobox.zip/HorizontallyScrollingComboBox/MainForm.cs
using System;
using System.Windows.Forms;
namespace HorizontallyScrollingComboBox
{
public partial class MainForm : Form
{
// Example project demonstrating applying a horizontal scrollbar to a standard combobox
// Original article and more at http://cyotek.com
#region Public Constructors
public MainForm()
{
InitializeComponent();
}
#endregion Public Constructors
#region Event Handlers
private void MainForm_Load(object sender, EventArgs e)
{
foreach (Control control in this.Controls)
{
if (control is ComboBox)
{
ComboBox box;
box = (ComboBox)control;
box.Items.Add("The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.");
box.Items.Add("Wolf zombies quickly spot the jinxed grave. Wolf zombies quickly spot the jinxed grave. Wolf zombies quickly spot the jinxed grave.");
box.Items.Add("The lazy major was fixing Cupid's broken quiver. The lazy major was fixing Cupid's broken quiver. The lazy major was fixing Cupid's broken quiver.");
box.SetHorizontalExtent();
}
}
}
#endregion Event Handlers
}
}
Files
- HorizontallyScrollingComboBox
