My user does not have .NET installed. Will he be able to run my Windows Forms application
No, the .NET runtime platform has to be on any machine that will run your Windows Forms application. Microsoft has made the .NET runtime platform installation (dotnetredist.exe) available as a free download from Microsoft .NET Framework Redistributable .
I programatically change a bound TextBox value, but the value does not get pushed back into the bound datasource. How can I make sure the DataSource is updated
You can call the EndCurrentEdit method on the bindingmanager for the TextBox. [C#] this.textBox1.Text = ‘XXXX’; //set the value this.textBox1.DataBindings[‘Text’].BindingManagerBase.EndCurrentEdit(); //end the edit [VB.NET] Me.TextBox1.Text = ‘XXXX’ Me.TextBox1.DataBindings(‘Text’).BindingManagerBase.EndCurrentEdit()
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();
In my datagrid, if I press tab to enter a column using a derived columnstyle, the column does not receive focus. Why
This behavior can be seen when you embedded a control like a textbox or combobox in your derived GridColumnStyle. If you press the tabkey slowly, you may see the cell get focus on the downkey and the cell lose focus on the upkey. One way to avoid this problem is to subclass the embedded control, and override its WndProc method, ignoring the KeyUp. [C#] public class MyCombo : ComboBox { private const int WM_KEYUP = 0x101; protected override void WndProc(ref System.Windows.Forms.Message m) { if(m.Msg == WM_KEYUP) { return; //ignore the keyup } base.WndProc(ref m); } } [VB.NET] Public Class MyTextBox Inherits TextBox Private WM_KEYUP As Integer = &H101 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_KEYUP Then Return ’ignore the keyup End If MyBase.WndProc(m) End Sub ’WndProc End Class ’MyTextBox
If I create an assembly, how can I see the assembly/components from with the VS.Net ‘Add…’ dialogs?
There are two ways in which this can be done. The first way is to use the provided Public assembly folder that is installed with VS.Net. This folder is: ‘C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\PublicAssemblies’ All assemblies in this folder will be picked up by the ‘Add Reference’ dialog under the ‘.NET’ tab, and the ‘Customize Toolbox’ under the ‘.NET Framework Components’ tab. Now, you are not limited to using this folder. You can specify your own public assembly folder by adding a key to the registry. If you look at the following key: ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\AssemblyFolders’, you will see a subkey named ‘PublicAssemblies’. This is where the path above is specified as a public assembly folder. To add your own folder, create a key (e.g. MyAssemblies), and set the default value to be the desired path.