private void Books_Load(object sender, EventArgs e) { DataSet dataalll = new DataSet(); dataalll.ReadXml("BD.xml"); try { int i = 0; int n = 0; foreach (DataRow row in dataalll.Tables["Books"].Rows) { DataBooks.Rows[n].Cells[2].Value = row["Genre"]; // то же самое с третьим столбцом DataBooks.Rows[n++].Cells[3].Value = row["YearPublication"]; // то же самое с четвертым столбцом string[] indexes = row["IndexesOfCurrentUsers"].ToString().Split('.'); foreach (string index in indexes) { Users.Add(new List <DataGridViewRow>()); try { Users[i].Add(friend.DataUserGrid.Rows[Convert.ToInt32(index)]); } catch (Exception) { continue; } } i++; } DataBooks.ClearSelection(); MoveObj.Focus(); } catch (NullReferenceException) { return; } this.DataBooks.SelectionChanged += new System.EventHandler(this.DataBooks_SelectionChanged); CountOfBooksTotal.Text = DataBooks.RowCount.ToString(); }
} // И ЭТО private void MainForm_Deactivate(object sender, EventArgs e) => MoveObj.Focus();
private void Search_form_Deactivate(object sender, EventArgs e) => MoveObj.Focus();
private void Books_Deactivate(object sender, EventArgs e) { MoveObj.Focus(); }