private void btnSelect_Click(object sender, EventArgs e) { try { if (dgvSearch.SelectedRows.Count > 0) { selectRow(dgvSearch.CurrentRow.Index); } else { this.DialogResult = DialogResult.Cancel; MessageView.ShowWarningMsg("Please select a row"); } } catch (Exception ex) { MessageView.ExceptionError(ex); } }
private void frmSearch_Load(object sender, EventArgs e) { try { if (dt.Rows.Count == 0) { MessageView.ShowWarningMsg("No record(s) found"); this.Dispose(); } dgvSearch.DataSource = dt; // hide extra fields for (int i = 0; i < dgvSearch.Columns.Count; i++) { if (maxColumnCount < (i + 1)) { dgvSearch.Columns[i].Visible = false; } } Utility.SetDatagridViewRow(dgvSearch); if (firstColWidth > 0 && dgvSearch.Columns.Count > 0) { dgvSearch.Columns[0].Width = firstColWidth; } if (secondColWidth > 0 && dgvSearch.Columns.Count > 1) { dgvSearch.Columns[1].Width = secondColWidth; } } catch (Exception ex) { MessageView.ExceptionError(ex); } }