How do I figure out if a particular client object has subscribed to one of my events?

In C#, you can do as follows: // In a Control derived class, for example, first store the handlers in a custom list. private EventHandler myHandlers; public new event EventHandler Click { add { this.myHandlers += value; } remove { this.myHandlers -= value; } } // This method will specify whether a particular delegate is subscribed. public bool IsSubscribed(Delegate del) { System.Delegate[] delegates = this.myHandlers.GetInvocationList(); foreach(Delegate d in delegates) { if(d == del) return true; } return false; } // Fire the Click event by parsing through your delegate list. protected override void OnClick(EventArgs e) { // First let my derived classes receive the Click event. foreach(Delegate d in this.myHandlers.GetInvocationList()) { d.DynamicInvoke(new object[]{this, e}); } } You can then find our if a delegate is subscribed as follows: // myControl is an instance of the above derived class. bool subscribed = this.myControl.IsSubscribed(new EventHandler(this.myControl_Clicked));

How can I programmatically create a new list for my ComboBox dropdown

Here are some snippets. (Courtesy of Michael Lang) [C#] DataTable list = new DataTable(); list.Columns.Add(new DataColumn(‘Display’, typeof(string))); list.Columns.Add(new DataColumn(‘Id’, typeof(int))); list.Rows.Add(list.NewRow()); list.Rows.Add(list.NewRow()); list.Rows.Add(list.NewRow()); list.Rows[0][0] = ‘one’; list.Rows[0][1] = 1; list.Rows[1][0] = ‘two’; list.Rows[1][1] = 2; list.Rows[2][0] = ‘three’; list.Rows[2][1] = 3; comboBox1.DataSource = list; comboBox1.DisplayMember = ‘Display’; comboBox1.ValueMember = ‘Id’; [VB.NET] Dim list As New DataTable() list.Columns.Add(New DataColumn(‘Display’, GetType(String))) list.Columns.Add(New DataColumn(‘Id’, GetType(Integer))) list.Rows.Add(list.NewRow()) list.Rows.Add(list.NewRow()) list.Rows.Add(list.NewRow()) list.Rows(0)(0) = ‘one’ ’ list.Rows(0)(1) = 1 ’ list.Rows(1)(0) = ‘two’ ’ list.Rows(1)(1) = 2 ’ list.Rows(2)(0) = ‘three’ ’ list.Rows(2)(1) = 3 ’ comboBox1.DataSource = list comboBox1.DisplayMember = ‘Display’ comboBox1.ValueMember = ‘Id’

How do I call a SQL stored procedure?

You can call stored procedures in basically the same manner as executing other SQL commands. When creating the SqlCommand, set the query string to be the name of the stored procedure, and then set the CommandType to be CommandType.StoredProcedure. if(sqlConn.State == ConnectionState.Closed)sqlConn.Open(); SqlCommand cmd = new SqlCommand(‘sp_my_stored_procedure’,sqlConn); cmd.CommandTimeout = 180; cmd.CommandType = CommandType.StoredProcedure; After you setup the command type, you need to pass in any parameters required for the stored procedure. Here is an example of one input and one output parameter. SqlParameter parm; parm = cmd.Parameters.Add(new SqlParameter(‘@oid’, SqlDbType.VarChar,50)); parm.Direction = ParameterDirection.Input; cmd.Parameters[‘@oid’].Value = OrderID; parm = cmd.Parameters.Add(new SqlParameter(‘@custName’, SqlDbType.VarChar,50)); parm.Direction = ParameterDirection.Output; If the stored procedure is returning a selection query at the end, you can fill your DataSet and retrieve any tables. SqlDataAdapter tempDA = new SqlDataAdapter(); tempDA.TableMappings.Add(‘your mapping’,’your mapping’); tempDA.SelectCommand = cmd; DataSet dataSet1 = new DataSet(); tempDA.Fill(dataSet1); DataTable resultTable = dataSet1.Tables[0]; Or, if no tables are being returned, you can execute the command as a non-query cmd.ExecuteNonQuery();