Click here to Skip to main content
15,904,351 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to get recent files Pin
Stefan Troschuetz25-Dec-06 21:21
Stefan Troschuetz25-Dec-06 21:21 
QuestionRe: How to get recent files Pin
ravichandratbv26-Dec-06 0:28
ravichandratbv26-Dec-06 0:28 
QuestionHow to Refresh previous page when next page is close Pin
jaganil25-Dec-06 19:09
jaganil25-Dec-06 19:09 
QuestionDynamic Crystal report generation Pin
shivabj25-Dec-06 18:51
shivabj25-Dec-06 18:51 
AnswerRe: Dynamic Crystal report generation Pin
shaz jazz26-Dec-06 0:14
shaz jazz26-Dec-06 0:14 
QuestionHow to read XML file from end/last using filestream pointer Pin
Praveen Raghuvanshi25-Dec-06 18:44
professionalPraveen Raghuvanshi25-Dec-06 18:44 
AnswerRe: How to read XML file from end/last using filestream pointer Pin
Nader Elshehabi26-Dec-06 7:28
Nader Elshehabi26-Dec-06 7:28 
QuestionSimulate typing in a texbox control? Newbie Needs Help! Pin
Basement Dweller25-Dec-06 18:25
Basement Dweller25-Dec-06 18:25 
Hello Freinds,
I am a newbie of about 4 months old, and have been trying to figure out how to simulate typing in a textbox control. I seem to have it all figured out except for the fact that the text appears all at once into the txtbox control rather than one character at a time and at a specified time delay.

What i have done so far:

I have a windows form with a button called (btnType)and a textbox(txtType).
When the button is clicked data is read from a comma deliminated file into the "string[]DeliminatedStrings" and from there the chosen deliminated string is loaded into a Char[] called "charSubstring" which has two parameters, "int Starting index, and Length of substring. The last "while" statement concatinates 1 letter of the substring from the deliminated file at a time, assigning it to the text property of the textbox control called txtType.

The "Tread.Sleep" command is used inside the "while" statement so that the text that is being assigned to the textbox control will be assigned at a delayed interval. I was hoping that at runtime this would simulate a user typing text, one character at a time, however, it appears that i have got something wrong because the text appears all at once into the textbox control.

I have messed with the delay times for the Thread.Sleep method but to no avail. It seems that all the delays happen first than the text is assigned all at once, instead of after each individual character assignment like i was hoping. Any help would be greatly appreciated.

Thanks Code project!



private void btnType_Click(object sender, System.EventArgs e)
{
StreamReader srReadFile = new StreamReader("C:/file.txt");
string readFile = string.Empty;
string[]DeliminatedStrings;
string txt2type;
char[] charSubstring;
int arrayPosition = 0;
int delay = 300;

while ((readFile = srReadFile.ReadLine())!= null)
{
DeliminatedStrings = readFile.Split(',');
txt2type = DeliminatedStrings[1];
charSubstring = txt2type.ToCharArray(0,txt2type.Length);

while(arrayPosition <= txt2type.Length - 1)
{
System.Threading.Thread.Sleep(delay);
txtType.Text = txtType.Text + charSubstring[arrayPosition].ToString();
arrayPosition ++;
}
}
}
AnswerRe: Simulate typing in a texbox control? Newbie Needs Help! Pin
Stefan Troschuetz25-Dec-06 21:14
Stefan Troschuetz25-Dec-06 21:14 
QuestionError while installing .NET 3.0 runtime. Pin
jdkulkarni25-Dec-06 18:03
jdkulkarni25-Dec-06 18:03 
AnswerRe: Error while installing .NET 3.0 runtime. Pin
Vega0225-Dec-06 19:36
Vega0225-Dec-06 19:36 
GeneralRe: Error while installing .NET 3.0 runtime. Pin
jdkulkarni25-Dec-06 19:52
jdkulkarni25-Dec-06 19:52 
GeneralRe: Error while installing .NET 3.0 runtime. Pin
Vincent Reynolds26-Dec-06 4:27
Vincent Reynolds26-Dec-06 4:27 
GeneralRe: Error while installing .NET 3.0 runtime. Pin
jdkulkarni26-Dec-06 17:27
jdkulkarni26-Dec-06 17:27 
QuestioncheckedlistBox .net 2.0 Pin
fmardani25-Dec-06 16:21
fmardani25-Dec-06 16:21 
Questionlistitem Pin
fmardani25-Dec-06 16:20
fmardani25-Dec-06 16:20 
AnswerRe: listitem Pin
Luc Pattyn25-Dec-06 17:11
sitebuilderLuc Pattyn25-Dec-06 17:11 
Questionc# application Pin
Dritt25-Dec-06 10:57
Dritt25-Dec-06 10:57 
AnswerRe: c# application Pin
Laubi25-Dec-06 11:24
Laubi25-Dec-06 11:24 
GeneralRe: c# application Pin
Dritt25-Dec-06 11:47
Dritt25-Dec-06 11:47 
GeneralRe: c# application Pin
Laubi25-Dec-06 12:56
Laubi25-Dec-06 12:56 
GeneralRe: c# application Pin
Laubi25-Dec-06 12:58
Laubi25-Dec-06 12:58 
AnswerRe: c# application Pin
Ravi Bhavnani25-Dec-06 11:27
professionalRavi Bhavnani25-Dec-06 11:27 
QuestionMouse speed Pin
conemajstor25-Dec-06 8:25
conemajstor25-Dec-06 8:25 
AnswerRe: Mouse speed Pin
Laubi25-Dec-06 11:15
Laubi25-Dec-06 11:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.