hey guys!
I just want to know one code.
you know this code for a listBox: listBox1.Items.Add("Text here");
and btw.. if I have 2 buttons like that it, the text i enter should not replace eachother
but I need the same code just for a textBox..
can anyone help?
Loading
Sam HobbsPosted Dec 12, 2011, 9:05 AM
I would however do it a little differently. The following is how I would do it. Regardless of how you do it, note what the Clear does.
if (textBox2.Text.Length > 0)
{
textBox1.Text += textBox2.Text + Environment.NewLine;
}
textBox2.Clear();
DavidPosted Dec 12, 2011, 8:35 AM
and If I klick 2 buttons like that, the text does not come after eachother like this: Some text Some text, it just replace eachother so it says: Some text. even if I click 100 times. That is what I mean :) hope you understand :D
Sam HobbsPosted Dec 11, 2011, 7:25 PM
If you do not have an answer yet then please clarify what you need.
You say "should not replace eachother". I am not sure I understand that. I assume that what you mean is that you want to look at all the text in the textbox to determine if the text is already in it. If so, then do you need to search each line looking for an entire line that matches or do you need to find portions of lines or something else?
I do not know what your requirements are. In your program, perhaps each line represents something. For example a title of a book represents a book but there are many other properties of a book. You could develop your code so that it manages the objects (books), not just the text (title).
Another way to remove the last line is:
{
string[] newlines = textBox1.Lines;
Array.Resize(ref newlines, newlines.Length - 1);
textBox1.Lines = newlines;
}
VulpesPosted Dec 11, 2011, 4:15 PM