コード例 #1
0
        private async void DataBooks_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                switch (e.Button)
                {
                case MouseButtons.Left when(DataBooks.CurrentRow.Selected):
                    DataBooksInf.Rows.Clear();

                    for (int i = 0; i < Users[DataBooks.CurrentRow.Index].Count; i++)
                    {
                        int n = DataBooksInf.Rows.Add();
                        (DataBooksInf.Rows[n].Cells[0].Value, DataBooksInf.Rows[n].Cells[1].Value) = GetDataRow(Users[DataBooks.CurrentRow.Index][i]);
                    }
                    DataBooksInf.ClearSelection();
                    Delete.Enabled = true;
                    Delete.Text    = "Удалить книгу";
                    break;

                case MouseButtons.Middle:
                    await helper.UnHideAllRowsAsyncUnsafe(DataBooks);

                    DataBooks.ClearSelection();
                    DataBooksInf.Rows.Clear();
                    Delete.Text    = "Удалить...";
                    Delete.Enabled = false;
                    InfoLabelBookUserCount.Visible = InfoLabelBookUserCountValue.Visible = false;
                    break;
                }
            }
            catch { }
        }
コード例 #2
0
 public void SelectAndScrollToBook(int indexOfBook)
 {
     DataBooks.SelectionChanged -= DataBooks_SelectionChanged;
     DataBooks.ClearSelection();
     DataBooks.Rows[indexOfBook].Selected      = true;
     DataBooks.FirstDisplayedScrollingRowIndex = indexOfBook;
     DataBooks.CurrentCell       = DataBooks.Rows[indexOfBook].Cells[3];
     DataBooks.SelectionChanged += DataBooks_SelectionChanged;
     DataBooks_SelectionChanged(1, new EventArgs());
 }
コード例 #3
0
        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();
        }