Exemplo n.º 1
0
        private void searchDbcMenuItem_Click(object sender, EventArgs e)
        {
            string retVal = Interaction.InputBox("Insert parameter", "Search");

            int col = 0;

            DataGridViewRow findedRow = DBCView.Rows.Cast <DataGridViewRow>().Where(x => x.Cells.Cast <DataGridViewCell>().Where(y =>
            {
                if (y.Value != null && y.Value.ToString().Contains(retVal) && y.RowIndex > DBCView.CurrentRow.Index)
                {
                    col = y.ColumnIndex;

                    return(true);
                }

                return(false);
            }).Count() > 0).FirstOrDefault();

            if (findedRow != null)
            {
                DBCView.ClearSelection();
                DBCView.Rows[findedRow.Index].Selected            = true;
                DBCView.Rows[findedRow.Index].Cells[col].Selected = true;
                DBCView.FirstDisplayedScrollingRowIndex           = findedRow.Index;
                DBCView.FirstDisplayedScrollingColumnIndex        = col;
                DBCView.Focus();
            }
        }
Exemplo n.º 2
0
        private void goToIDMenuItem_Click(object sender, EventArgs e)
        {
            string retVal = Interaction.InputBox("Insert ID", "Go to ID");

            int line = 0;

            Int32.TryParse(retVal, out line);

            DataGridViewRow findedRow = DBCView.Rows.Cast <DataGridViewRow>().Where(row => row.Cells[0].Value.ToString() == line.ToString()).FirstOrDefault();

            if (findedRow != null)
            {
                DBCView.ClearSelection();
                DBCView.Rows[findedRow.Index].Selected  = true;
                DBCView.FirstDisplayedScrollingRowIndex = findedRow.Index;
                DBCView.Focus();
            }
        }