Hi
I am having a richtextbox and a listbox.
From l;istbox, i select one item and attach that item to the richtextbox data.
If list box has data like custname,customernumber and
In rich textbox, the data is as given bellow
DEAR ---------
Nice meeting you.
Beside Dear, i will be attaching the field from listbox. The output shud be
Dear Customername
Nice meeting you.
Instead the word customer name is coming in next line. The text that is added from listbox is not appending to the existing text in richtextbox.
Please help.
My question may be beating around the bush, Apologies for the same.
Thanks
Kirtan PatelPosted Oct 23, 2008, 1:29 PM
Try it
private void btnSendToRtf_Click(object sender, EventArgs e)
{
appendtext_to_cursor_position(richTextBox1, listBox1.SelectedItem.ToString(), richTextBox1.SelectionStart);
}
void appendtext_to_cursor_position(RichTextBox rtf, String str, int positiontoinsert)
{
int CurrentCeret = rtf.SelectionStart + str.Length;
rtf.Select(positiontoinsert, rtf.TextLength - positiontoinsert);
str+= rtf.SelectedText;
rtf.SelectedText = String.Empty;
rtf.AppendText(str);
rtf.SelectionStart = CurrentCeret;
}
Happy Coding :-)
sairamPosted Oct 23, 2008, 3:07 PM
Hi Kirtan,
Thanks a ton once again .
I have a request. I posted one more question with subject richtextbox challenge. Can you please look into that when u r free and help me. If u need any further info reg that question, i can send u the screen shots to your email ID.
thanks
sairamPosted Oct 23, 2008, 11:47 AM
Hi mamta,
I tried to set Wordwrap property to False but this did not help me. :-(
Thanks
Sairam
sairamPosted Oct 23, 2008, 3:08 AM
Thanks fr ur reply . I will check it tomorrow morning once i go to office. If you dont mind, can u please have a look on the other question i posted when ever u r free.
Sincere thanks,
Sairam
Mamta MPosted Oct 23, 2008, 2:50 AM
Hi sairam,
Have you set the WordWrap property of RichTextBox to false? If not, then please do that and check. It will work.
Regards,
Mamta