How can I sort a column in a ListView
This Microsoft KB article provides a step by step sample.
How to get rid of the gong sound when enter is hit in textbox?
Subclass from TextBox, override ProcessDialogKey and do the following: protected override bool ProcessDialogKey(Keys keyData) { if(keyData == Keys.Return) { return true; } else if(keyData == Keys.Escape) { return true; } else return base.ProcessDialogKey(keyData); } The idea is to prevent the base class from processing certain keys.
How can I get button to fire a click event at specific time intervals while the mouse is down like a scrollbar button?
Shawn Burke posted the following solution on the microsoft.public.dotnet.framework.windowsforms newsgroup. public class RepeatButton : Button { private Timer timer1; public int Interval { get { return Timer.Interval; } set { Timer.Interval = value; } } private Timer Timer { get { if (timer1 == null) { // create and setup our timer. timer1 = new Timer(); timer1.Tick += new EventHandler(OnTimer); timer1.Enabled = false; } return timer1; } } protected override void OnMouseDown(MouseEventArgs me) { base.OnMouseDown(me); // turn on the timer Timer.Enabled = true; } protected override void OnMouseUp(MouseEventArgs me) { // turn off the timer Timer.Enabled = false; base.OnMouseUp(me); } private void OnTimer(object sender, EventArgs e) { // fire off a click on each timer tick // OnClick(EventArgs.Empty); } }
How can I turn off editing in the textbox portion of a ComboBox, restricting the user to selecting only those options in the drop list
Set the combobox’s DropDownStyle property to DropDownList .
I have hidden (column width = 0) columns on the right side of my datagrid, but tabbing does not work properly. How can I get tabbing to work
As you tabbed to the right side of your grid, you have to tabbed through these zero width column and that is causing the tab key to appear not to work properly. One solution is to handle the grid’s CurrentCellChanged event, and if you are on a border cell (among the hidden columns), then explicitly set the proper currentcell. //columns 3-6 are hidden with 0-column width… private int LEFTHIDDENCOLUMN = 3; private int RIGHTHIDDENCOLUMN = 6; private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { if(dataGrid1.CurrentCell.ColumnNumber == LEFTHIDDENCOLUMN) dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentCell.RowNumber + 1, 0); else if(dataGrid1.CurrentCell.ColumnNumber == RIGHTHIDDENCOLUMN) dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentCell.RowNumber, LEFTHIDDENCOLUMN – 1); }