Click to See Complete Forum and Search --> : Display LINQ results inside a RichTextBox - howto


rakk
February 11th, 2009, 10:58 AM
I have this LINQ code:

var ang = from employee e1 in db.employees
orderby e1.hire_date descending
select new { e1.fname, e1.lname, e1.hire_date };



And I want to display the results into a RichTextBox.

I tried richTextBoxname.toString() but obviously did not worked.

Can anyone explain me how to display results in the richtextbox, since
I am not very familiar with C#.

Thank you.

dannystommen
February 11th, 2009, 11:38 AM
you need to append the text to the richtextbox\


richtextbox.AppendText(""myText");


Enumerate through your LINQ result and append each line to the richtextbox

eclipsed4utoo
February 11th, 2009, 02:25 PM
foreach (var a in ang)
{
richTextBox1.AppendText(a.fname + "\t" + a.lname + "\t" + a.hire_date);
}

rakk
February 11th, 2009, 04:21 PM
Thank you guys :)