/// <summary> /// button Search Click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void button_search_Click(object sender, System.EventArgs e) { if (textBox_search.TextLength > 0 && textBox_search.Text != textBox_search.ToolTipText && Search != null) { DataGridViewColumn c = null; if (comboBox_columns.SelectedIndex > 0 && _columnsList != null && _columnsList.GetColumnCount(DataGridViewElementStates.Visible) > 0) { DataGridViewColumn[] cols = _columnsList.Cast <DataGridViewColumn>().Where(col => col.Visible).ToArray <DataGridViewColumn>(); if (cols.Length == comboBox_columns.Items.Count - 1) { if (cols[comboBox_columns.SelectedIndex - 1].HeaderText == comboBox_columns.SelectedItem.ToString()) { c = cols[comboBox_columns.SelectedIndex - 1]; } } } AdvancedDataGridViewSearchToolBarSearchEventArgs args = new AdvancedDataGridViewSearchToolBarSearchEventArgs( textBox_search.Text, c, button_casesensitive.Checked, button_wholeword.Checked, button_frombegin.Checked ); Search(this, args); } }
private void advancedDataGridViewSearchToolBar_main_Search(object sender, Zuby.ADGV.AdvancedDataGridViewSearchToolBarSearchEventArgs e) { bool restartsearch = true; int startColumn = 0; int startRow = 0; if (!e.FromBegin) { bool endcol = advancedDataGridView_main.CurrentCell.ColumnIndex + 1 >= advancedDataGridView_main.ColumnCount; bool endrow = advancedDataGridView_main.CurrentCell.RowIndex + 1 >= advancedDataGridView_main.RowCount; if (endcol && endrow) { startColumn = advancedDataGridView_main.CurrentCell.ColumnIndex; startRow = advancedDataGridView_main.CurrentCell.RowIndex; } else { startColumn = endcol ? 0 : advancedDataGridView_main.CurrentCell.ColumnIndex + 1; startRow = advancedDataGridView_main.CurrentCell.RowIndex + (endcol ? 1 : 0); } } DataGridViewCell c = advancedDataGridView_main.FindCell( e.ValueToSearch, e.ColumnToSearch != null ? e.ColumnToSearch.Name : null, startRow, startColumn, e.WholeWord, e.CaseSensitive); if (c == null && restartsearch) { c = advancedDataGridView_main.FindCell( e.ValueToSearch, e.ColumnToSearch != null ? e.ColumnToSearch.Name : null, 0, 0, e.WholeWord, e.CaseSensitive); } if (c != null) { advancedDataGridView_main.CurrentCell = c; } }