|
OK, thank you.
Can you see anywhere in my code why it is that the strings are being added together?
For example, if I type:
Hello.
Then I type hello again, it would output as
hellohello.
I have tried to clear the strings atraight after use but no luck.
Thank you
Steve
|
|
|
|
|
stephen.darling wrote: I have tried to clear the strings atraight after use but no luck
stephen.darling wrote: richTextBoxOutput.Text += you += input + ("\n")
two very strange statements.
|
|
|
|
|
Luc Pattyn wrote: two very strange statements.
Maybe so, but this is me we are talking about, you proberbly know by bow how difficult it is to explain things to you.
You would think, as a Biomedical Scientist that I would not have a issue, but when it comes to a new area, for me, it is
I am awaiting delivery of my new book, head first c#, so hopefully I can start learning properly.
Regards,
Steve
|
|
|
|
|
Here's an extremely cheesy hack. It's only merit (if you can call it that) is that it's quick to write. For grins, you can show/hide a marquee style progress bar before/after calling GenerateResponse() to simulate processing.
string GenerateResponse
(string input)
{
DateTime start = DateTime.Now;
int pause = 3000;
while ((DateTime.Now - start).TotalMilliseconds < pause) {
Application.DoEvents();
}
return "Some response based on " + input;
}
/ravi
|
|
|
|
|
You're a dirty, dirty bird!
|
|
|
|
|
Hence the disclaimers.
If all he wants to do is write a fun little app, it'll do. But I would never put anything like this in my freeware or commercial apps.
/ravi
|
|
|
|
|
How about this?
string GenerateResponse
(string input)
{
DateTime start = DateTime.Now;
int pause = 3000;
loop:
if ((DateTime.Now - start).TotalMilliseconds >= pause) {
return "Some response based on " + input;
}
Application.DoEvents();
goto loop;
}
/ravi
|
|
|
|
|
Now that's just sad, so, so sad
|
|
|
|
|
Go on - 5 it. You know you wanna.
/ravi
|
|
|
|
|
If by "5 it", you mean "punch it in the face with my fist", then I'm sure he does want to.
|
|
|
|
|
Having trouble seeing the smilies?
/ravi
|
|
|
|
|
I too was joking (making reference to hands having 5 fingers). Didn't feel the need to taint the joke with an emotion though.
|
|
|
|
|
I aasigned Text to the Textbox from code behind like "Showing <b>"+Test+" </b> message ...";
Its not displaying Test in bold.How can I do this
|
|
|
|
|
Since you refer to 'code behind' your question is probably in the wrong forum. It should more properly be in (at a guess) the ASP or WPF forum.
In Windows Forms programming the TextBox cannot display text styles from tags, only from being assigned a boldened font.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
If you use classic Windows Form App then you need to use TextBox.Font[^]
In Wpf, it is FontWeight
|
|
|
|
|
I aasigned Text to the Textbox from code behind like "Showing "+Test+" message ...";
Its not displaying Test in bold.How can I do this
|
|
|
|
|
Please try to avoid posting the same question more than once!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm taking this exam in a little more then a week from now and am searching for some practice questions. I found some and didn't always understand the question so I tried it out. "It didn't work". Really, the code they gave as the answer did not what the question requested.
I'm curious if the source is trustworthy or if I'm going bananas here (or both ) ??
thanks.
below an example of such a question and expected answer:
(apologies for the formatting)
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You write the following code fragment.
<StackPanel TextBox.PreviewTextInput="StackPanel_PreviewTextInput">
<TextBox Name="TxtBoxA"/>
<TextBox Name="TxtBoxB"/>
<TextBox Name="TxtBoxC"/>
</StackPanel>
You create an event handler named StackPanel_PreviewTextInput. You also have a collection of strings named Keywords.
You need to ensure that TxtBoxA and TxtBoxB do not contain any of the strings in the Keywords collections.
Which code segment should you use?
A. private void StackPanel_PreviewTextInput(
object sender, TextCompositionEventArgs e)
{ FrameworkElement feSource = sender as FrameworkElement;
if (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB")
{ foreach(string keyword in Keywords)
{
if(e.Text.Contains(keyword)) { e.Handled = false;
return;
}
}} e.Handled = true;
} }
B. private void StackPanel_PreviewTextInput(
object sender, TextCompositionEventArgs e) {
FrameworkElement feSource = e.Source as FrameworkElement;
f (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB")
f (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB") {
foreach(string keyword in Keywords)
{
if(e.Text.Contains(keyword)) { e.Handled = false;
return;
}
} e.Handled = true;
C. private void StackPanel_PreviewTextInput(
object sender, TextCompositionEventArgs e)
{
FrameworkElement feSource = sender as FrameworkElement;
if (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB")
{ foreach(string keyword in Keywords)
{ if(e.Text.Contains(keyword)) {
e.Handled = true;
return; }
} e.Handled = false;
} }
D. private void StackPanel_PreviewTextInput(
object sender, TextCompositionEventArgs e)
{ FrameworkElement feSource = e.Source as FrameworkElement;
if (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB")
{
foreach(string keyword in Keywords)
{ if(e.Text.Contains(keyword)) {
e.Handled = true;
return;
} } e.Handled = false;
}
}
Answer D is the right answer...
However, following the question I found following to actually do what was requested:
(except when you paste the word in the textbox so even the idea of using this code for the requested functionality is not really ideal)
the problem was that e.Text only gave the typed character and not the entire contents.
private void StackPanel_PreviewTextInput(object sender, TextCompositionEventArgs e){
FrameworkElement feSource = e.Source as FrameworkElement;
if (feSource.Name == "TxtBoxA" || feSource.Name == "TxtBoxB") {
foreach (string keyword in Keywords) {
lbl_info1.Content = e.Text;
if ( ((((TextBox)feSource).Text)+e.Text).Contains(keyword)) {
e.Handled = true;
return;
}
}
e.Handled = false;
}
}
V.
|
|
|
|
|
hi !
I am trying to get the url referer in http handler. all the broweser is giving currect valu except safari. It is null evry time. Can you pleaes tell me how do i get the url referer in safari
Thank you.
|
|
|
|
|
This[^] should be the correct place to ask.
Best wishes,
Navaneeth
|
|
|
|
|
Hello.
I have a form that is a multi page wizard.
It will ask the user for quite a bit informtion, some text, some int values and other.
When it is finished collecting the data, I would like to pass it into a seperate object that will "process" the data, and respond with a string or other value to the main form.
What is the best way to approach this, as all my objects so far have only needed to pass in one or 2 auguments or data values.
Thank you
Steve
|
|
|
|
|
Anything gathered from a manual input cannot be considered a large amount of data.
Presumably you have a class with fields (properties or variables) that represent the information gathered from the form OR you have a dictionary type object with key/values to retain the data. You should pass the object (class or dictionary/list) to the processing method(s).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
When I said a large amount of data, I simply meant alot of fields from a wizard form.
My main form is a wizard, Form1, with several pages. Each page contains approx 5-6 text boxes or some drop down controls etc.
When the user has finished clicking next for each page of the wizard, and we get to the last page, are you sugesting I then pass the object of my main form into the object for processing?
If so, how would I do that?
Thank you
Steve
|
|
|
|
|
stephen.darling wrote: are you sugesting I then pass the object of my main form into the object for processing?
Not the object of main form, but the object where you have collected the data. Consider a form with two textboxes and Name and Age. You'd create a type like,
class PersonInfo
{
public string Name { get; set; }
public string Age { get; set; }
} and pass instance of this object to the processing routine.
DataBinding in windows forms makes this easy as it allows you to bind object fields directly to the control. Your object will get updated automatically when value changes on the control.
Best wishes,
Navaneeth
|
|
|
|
|
Aw thank you.
That helps alot.
Steve
|
|
|
|