How do I force the changes in base class fields to be serialized via a base class property in the inherited type’s designer?

Sometimes you might want to let the designer serializer serialize the changes in base fields via a property rather than the field itself using the AccesssedThroughProperty attribute as follows: public class MyBaseForm : Form { [AccessedThroughProperty(‘MyList’)] private ArrayList myList; public ArrayList MyList { return this.myList; } } Then when the above form is inherited and items get added to the inherited form’s designer, code will be added as follows in the inherited form’s InitializeComponent: private void InitializeComponent() { … … … … this.MyList.Add(aNewItem); … … … … }

How can I prevent the beep when enter is hit in textbox?

You can prevent the beep when the enter key is pressed in a TextBox by deriving the TextBox and overriding OnKeyPress. [C#] public class MyTextBox : TextBox { protected override void OnKeyPress(KeyPressEventArgs e) { if(e.KeyChar == (char) 13) e.Handled = true; else base.OnKeyPress (e); } } [VB.NET] Public Class MyTextBox Inherits TextBox Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs) If e.KeyChar = CChar(13) Then e.Handled = True Else MyBase.OnKeyPress(e) End If End Sub ’OnKeyPress End Class ’MyTextBox

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()