After scrolling with the mouse wheel on a selected row in a DataGrid I cannot get it back into view. Is there a work around?
When you select a row in the DataGrid and scroll it out of view using the mouse wheel, you cannot get it back into view. The following is a workaround posted by one Windows Forms User: [C#] this.dataGrid1.MouseWheel+=new MouseEventHandler(dataGrid1_MouseWheel); private void dataGrid1_MouseWheel(object sender, MouseEventArgs e) { this.dataGrid1.Select(); } [VB.NET] AddHandler Me.dataGrid1.MouseWheel, addressof dataGrid1_MouseWheel Private Sub dataGrid1_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) Me.dataGrid1.Select() End Sub
How do I print a document using .NET?
This can be done using the Process class and specifying the verb as ‘Print’. This is the equivalent of right clicking and selecting print in the windows shell. Here is the code snippet that prints documents like MS Excel, MS Word, pdf etc.. // In C#.NET //Print an Excel document Process pr = new Process(); pr.StartInfo.Verb = ‘Print’; pr.StartInfo.FileName = ‘Sample.xls’; pr.Start(); ’ In VB.NET ’Print an Excel document Dim pr As Process = New Process() pr.StartInfo.Verb = ‘Print’ pr.StartInfo.FileName = ‘Sample.xls’ pr.Start()
How can I make the DataGrid column be blank and not display (null) as the default value?
When you go to a new row in a DataGrid, the columns display (null). To prevent this behavior and make all the columns be empty, you can set the DefaultValue property of the DataColumn to be String.Empty.
How can I ensure that a node is selected when the user clicks along the line of a node?
A click event will be fired but a node will not be selected when the user clicks to the right of a node. This code snippets show how you can ensure that a node is selected in this scenario: [C#] private void treeView1_Click(object sender, System.EventArgs e) { treeView1.SelectedNode = treeView1.GetNodeAt(treeView1.PointToClient(Cursor.Position)); } [VB.NET] Private Sub treeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) treeView1.SelectedNode = treeView1.GetNodeAt(treeView1.PointToClient(Cursor.Position)) End Sub
How can I create a thumbnail of a bitmap?
You can use the GetThumbnailImage method to generate and display a thumbnail of a bitmap as shown below: [C#] public bool ThumbnailCallback() { return false; } //Generate a thumbnail of the bitmap and display it in a PictureBox Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap = new Bitmap(‘C:\\images\\MyBitMap.bmp’); this.pictureBox1.Image = (Bitmap) myBitmap.GetThumbnailImage(150,75,myCallback, IntPtr.Zero);