예제 #1
0
        private bool SelectRowById(Id id)
        {
            if ((dataGridView1.Rows?.Count ?? 0) < 1)
            {
                return(false);
            }

            bool found = false;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Index < 0) // archaic shit
                {
                    continue;
                }

                CitationSelectorModel cit = (CitationSelectorModel)row.DataBoundItem;
                if ((cit?.Model.Id ?? Id.Empty) == id) // everything is possible
                {
                    SelectRow(row.Index);
                    found = true;
                    break;
                }
            }

            return(found);
        }
예제 #2
0
        private void SelectRow(int idx)
        {
            dataGridView1.ClearSelection();
            dataGridView1.Rows[idx].Selected = true;
            dataGridView1.CurrentCell        = dataGridView1.Rows[idx].Cells[0];

            CitationSelectorModel cit = (CitationSelectorModel)dataGridView1.Rows[idx].DataBoundItem;

            SelectedCitation = (Citation)cit.Model;
        }