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); } }

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); }

How can I make the datagrid have no currentcell

There appears to be no method to turn off a currentcell. When a cell is being edited, it is the TextBox embedded in the columnstyle that has the focus, and is displaying the highlighted text. You will notice in this situation, if you click the grid’s title bar above the column headers, this TextEdit control loses focus, and the datagrid appears to have no current cell. We can simulate this click from code, and use it to expose a method in our datagrid to SetNoCurrentCell. Below is some code to illustrate this idea. public class MyDataGrid : DataGrid { public const int WM_LBUTTONDOWN = 513; // 0x0201 public const int WM_LBUTTONUP = 514; // 0x0202 [System.Runtime.InteropServices.DllImport(‘user32.dll’)] static extern bool SendMessage(IntPtr hWnd, Int32 msg, Int32 wParam, Int32 lParam); public void SetNoCurrentCell() { //click on top left corner of the grid SendMessage( this.Handle, WM_LBUTTONDOWN, 0, 0); SendMessage( this.Handle, WM_LBUTTONUP, 0, 0); } } Here is some VB code. Public Class MyDataGrid Inherits DataGrid Public WM_LBUTTONDOWN As Integer = 513 Public WM_LBUTTONUP As Integer = 514 Shared _ Function SendMessage(hWnd As IntPtr, msg As Int32, wParam As Int32, lParam As Int32) As Boolean Public Sub SetNoCurrentCell() ’click on top left corner of the grid SendMessage(Me.Handle, WM_LBUTTONDOWN, 0, 0) SendMessage(Me.Handle, WM_LBUTTONUP, 0, 0) End Sub ’SetNoCurrentCell End Class ’MyDataGrid

How do I display the PrintPreview maximized and control its zooming

You can use the WindowState property of the PrintPreviewDialog class to bring the PrintPreview maximized. To handle zooming, the PrintPreviewDialog has a property, PrintPreviewControl. PrintPreviewControl owns a Zoom property that allows you to set the zoom factor of the PrintPreview.