Welcome

Welcome Anonymous

Friday, April 30, 2010

Auto Complete Feature for any control

SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=tts;Integrated Security=True");

//creat auto complete Collection

AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

//get the data from database

SqlDataAdapter da1 = new SqlDataAdapter("select name from contacts ", con);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
for (int i = 0; i < dt1.Rows.Count; i++)
{
//add the student name into auto complete collection
collection.Add(dt1.Rows[i].ItemArray[0].ToString());
}
}

//after adding the student names into auto complete collection bind the collection to Combobox

toolStripComboBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
toolStripComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
toolStripComboBox1.AutoCompleteCustomSource = collection;

Saving Text in Wav Format

Include the name space System.Speech
saveFileDialog1.ShowDialog();

string str = saveFileDialog1.FileName;

System.Speech.Synthesis.SpeechSynthesizer synth = new
System.Speech.Synthesis.SpeechSynthesizer();

synth.SetOutputToWaveFile(str+".wav" );
synth.Speak(textBox1.Text);

MessageBox.Show("File Saved Successfully");
synth.Dispose();

Converting Text to Speech

Include the name space System.Speech
System.Speech.Synthesis.SpeechSynthesizer sp = new System.Speech.Synthesis.SpeechSynthesizer();

sp.Volume = 100;
sp.Speak(textBox1.Text);
sp.Dispose();

Serial Port Communication

Include the namespace System.IO.Ports
SerialPort sp = new SerialPort();
Sp.Open();
sp.WriteLine(textBox1.Text);

Image Uploading

string imgpath = this.FileUpload1.FileName;

FileUpload1.SaveAs(Server.MapPath("~//images//" + imgpath.ToString()));

iname = "~/images/" + imgpath.ToString();