На самом деле GotFocus является правильным событием (сообщение действительно), что Вы интересуетесь, с тех пор неважно, как Вы добираетесь до управления you’ll, получают это даже в конечном счете. Вопрос состоит в том, когда делают Вы называете SelectAll ().
Попытка это:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus);
}
private delegate void SelectAllDelegate();
private IAsyncResult _selectAllar = null; //So we can clean up afterwards.
//Catch the input focus event
void textBox1_GotFocus(object sender, EventArgs e)
{
//We could have gotten here many ways (including mouse click)
//so there could be other messages queued up already that might change the selection.
//Don't call SelectAll here, since it might get undone by things such as positioning the cursor.
//Instead use BeginInvoke on the form to queue up a message
//to select all the text after everything caused by the current event is processed.
this._selectAllar = this.BeginInvoke(new SelectAllDelegate(this._SelectAll));
}
private void _SelectAll()
{
//Clean-up the BeginInvoke
if (this._selectAllar != null)
{
this.EndInvoke(this._selectAllar);
}
//Now select everything.
this.textBox1.SelectAll();
}
}
Вы можете использовать String.Join
, чтобы создать строку с разделителями-запятыми.
string DetailsOfSickness =
String.Join(", ", (
from t2 in illnesses
join ai1 in absenceIllnesses on t2.IllnessID equals ai1.IllnessID
select t2.IllnessName).ToArray());
Что-то вроде этого должно сработать:
DetailsOfSickness = String.Join(", ", (
from t2 in Illnesses
join ai1 in AbsenceIllnesses on t2.IllnessID equals ai1.IllnessID
select t2.IllnessName).ToArray());