.NET
.NET Form Transparency
A little tip on the .NET Form Transparency.
The following code shall provide a simple way to adjust the form transparency using the mouse wheel button.
//=== in the initialization section insert this:
this.MouseWheel += new MouseEventHandler(TransparencyHandle);
//=== in the form’s class :
private void TransparencyHandle(object sender, MouseEventArgs e)
{
if (e.Delta > 0)
{
this.Opacity = this.Opacity + 0.05;
}
else
{
this.Opacity = this.Opacity – 0.05;
}
}
This should do it.
.NET TEXT-TO-SPEECH example
Some methods to implement text-to-speech in a .NET application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public void Sing(string vMessage) { BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerAsync(vMessage); } private static void bw_DoWork(object sender, DoWorkEventArgs e) { SpVoice voice = new SpVoice(); voice.Speak(e.Argument.ToString(), SpeechVoiceSpeakFlags.SVSFDefault); } Sing("Hello"); |
.NET DataSet Creation
private void GetData(string selectCommand)
{
try
{
// Specify a connection string. Replace the given value with a
// valid connection string for a Northwind SQL Server sample
// database accessible to your system.
String connectionString =
“Integrated Security=SSPI;Persist Security Info=False;” +
“Initial Catalog=Northwind;Data Source=localhost”;
// Create a new data adapter based on the specified query.
dataAdapter = new SqlDataAdapter(selectCommand, connectionString);
// Create a command builder to generate SQL update, insert, and
// delete commands based on selectCommand. These are used to
// update the database.
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
// Populate a new data table and bind it to the BindingSource.
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
bindingSource1.DataSource = table;
// Resize the DataGridView columns to fit the newly loaded content.
dataGridView1.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
catch (SqlException)
{
MessageBox.Show(“To run this example, replace the value of the ” +
“connectionString variable with a connection string that is ” +
“valid for your system.”);
}
}