I need to perform certain custom processing whenever an MDI child form is added to/removed from the MDIContainer form. How do I determine this?

MDIContainer forms have an MDIClient child window and it is to this MDIClient window that MDI child forms are parented. The MDIClient’s ControlAdded/ControlRemoved events will be fired whenever a child form is added or removed. You can subscribe to these events and add the required processing code from within the handlers. // From within the MDIContainer form, subscribe to the MDIClient’s ControlAdded/ControlRemoved events foreach(Control ctrl in this.Controls) { if(ctrl.GetType() == typeof(MdiClient)) { ctrl.ControlAdded += new ControlEventHandler(this.MDIClient_ControlAdded); ctrl.ControlRemoved += new ControlEventHandler(this.MDIClient_ControlRemoved); break; } } protected void MDIClient_ControlAdded(object sender, ControlEventArgs e) { Form childform = e.Control as Form; Trace.WriteLine(String.Concat(childform.Text, ‘ – MDI child form was added.’)); } protected void MDIClient_ControlRemoved(object sender, ControlEventArgs e) { Trace.WriteLine(String.Concat(e.Control.Text, ‘ – MDI child form was removed.’)); }

How can I import a CSV file into a DataTable

Here is a solution suggested by Elan Zhou (MS) on the microsoft.public.dotnet.languages.vb newsgroup. You can also use the following code: 1. Put a DataGrid on the form. 2. Try the following sample code: (Suppose the csv is c:\test.csv.) Imports System.Data Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim objDataset1 As DataSet() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sConnectionString As String = ‘Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=Text;’ Dim objConn As New OleDbConnection(sConnectionString) objConn.Open() Dim objCmdSelect As New OleDbCommand(‘SELECT * FROM test.csv’, objConn) Dim objAdapter1 As New OleDbDataAdapter() objAdapter1.SelectCommand = objCmdSelect Dim objDataset1 As New DataSet() objAdapter1.Fill(objDataset1, ‘Test’) DataGrid1.DataSource = objDataset1.Tables(0).DefaultView objConn.Close() End Sub End Class

GDI+ Programming: Creating Custom Controls using C#

GDI+ Programming: Creating Custom Controls using C# by Eric White, Chris Garrett. Wrox Press Inc; ISBN: 1861006314 The title of the this book is kind of misleading. It is an excellent introduction to GDI+. In addition to GDI+ there is also some information on control designers that will be useful to control authors.

C# Design Patterns

C# Design patterns by James W. Cooper. ISBN: 0201844532 This is a good book to learn about patterns through a C#/Windows Forms lens. Several of the samples are UI related and use Windows Forms.