protected override void OnKeyPress(KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Back) { return; } if (this.sccomp.Count > 0) { DialogInlineSearch s = new DialogInlineSearch(e.KeyChar.ToString()); Point p = this.btnOK.PointToScreen(Point.Empty); s.SetBounds(p.X - 13, p.Y - 18, s.Width, s.Height); if (s.ShowDialog() == DialogResult.OK) { var selected_row = this.dgv.Rows.Cast <DataGridViewRow>().Where(r => ((string)r.Cells[this.col_compnam.Name].Value).StartsWith(s.keyword)).FirstOrDefault(); if (selected_row != null) { selected_row.Cells[this.col_compnam.Name].Selected = true; } } } //base.OnKeyPress(e); }
private void btnSearch_Click(object sender, EventArgs e) { if (this.sccomp.Count > 0) { DialogInlineSearch s = new DialogInlineSearch(string.Empty); Point p = this.btnOK.PointToScreen(Point.Empty); s.SetBounds(p.X - 13, p.Y - 18, s.Width, s.Height); if (s.ShowDialog() == DialogResult.OK) { var selected_row = this.dgv.Rows.Cast <DataGridViewRow>().Where(r => ((string)r.Cells[this.col_compnam.Name].Value).StartsWith(s.keyword)).FirstOrDefault(); if (selected_row != null) { selected_row.Cells[this.col_compnam.Name].Selected = true; } } } }