Exemplo n.º 1
0
        /// <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);
            }
        }
        public void DataGridViewColumnCollection_Add_CustomAutoSizeMode_Success(bool columnHeadersVisible, bool visible, bool frozen, DataGridViewAutoSizeColumnsMode columnsAutoSizeMode, DataGridViewAutoSizeColumnMode autoSizeMode)
        {
            using var control = new DataGridView
                  {
                      AutoSizeColumnsMode  = columnsAutoSizeMode,
                      ColumnHeadersVisible = columnHeadersVisible
                  };
            DataGridViewColumnCollection collection = control.Columns;

            using var column1 = new DataGridViewColumn(new SubDataGridViewCell())
                  {
                      AutoSizeMode = autoSizeMode,
                      Frozen       = frozen,
                      Visible      = visible
                  };
            using var column2 = new DataGridViewColumn(new SubDataGridViewCell())
                  {
                      AutoSizeMode = autoSizeMode,
                      Frozen       = frozen,
                      Visible      = visible
                  };

            // Add one.
            collection.Add(column1);
            Assert.Equal(new DataGridViewColumn[] { column1 }, collection.Cast <DataGridViewColumn>());
            Assert.Same(control, column1.DataGridView);
            Assert.Equal(0, column1.Index);
            Assert.Equal(0, column1.DisplayIndex);
            Assert.False(control.IsHandleCreated);

            // Add another.
            collection.Add(column2);
            Assert.Equal(new DataGridViewColumn[] { column1, column2 }, collection.Cast <DataGridViewColumn>());
            Assert.Same(control, column1.DataGridView);
            Assert.Equal(0, column1.Index);
            Assert.Equal(0, column1.DisplayIndex);
            Assert.Same(control, column2.DataGridView);
            Assert.Equal(1, column2.Index);
            Assert.Equal(1, column2.DisplayIndex);
            Assert.False(control.IsHandleCreated);
        }
        public void DataGridViewColumnCollection_Add_CustomColumnSortModeAndSelectionMode_Success(DataGridViewSelectionMode selectionMode, DataGridViewColumnSortMode sortMode)
        {
            using var control = new DataGridView
                  {
                      SelectionMode = selectionMode
                  };
            DataGridViewColumnCollection collection = control.Columns;

            using var column1 = new DataGridViewColumn(new SubDataGridViewCell())
                  {
                      SortMode = sortMode
                  };
            using var column2 = new DataGridViewColumn(new SubDataGridViewCell())
                  {
                      SortMode = sortMode
                  };

            // Add one.
            collection.Add(column1);
            Assert.Equal(new DataGridViewColumn[] { column1 }, collection.Cast <DataGridViewColumn>());
            Assert.Same(control, column1.DataGridView);
            Assert.Equal(0, column1.Index);
            Assert.Equal(0, column1.DisplayIndex);
            Assert.False(control.IsHandleCreated);

            // Add another.
            collection.Add(column2);
            Assert.Equal(new DataGridViewColumn[] { column1, column2 }, collection.Cast <DataGridViewColumn>());
            Assert.Same(control, column1.DataGridView);
            Assert.Equal(0, column1.Index);
            Assert.Equal(0, column1.DisplayIndex);
            Assert.Same(control, column2.DataGridView);
            Assert.Equal(1, column2.Index);
            Assert.Equal(1, column2.DisplayIndex);
            Assert.False(control.IsHandleCreated);
        }
Exemplo n.º 4
0
 public static DataGridViewColumn GetColumnFromPropertyName(this DataGridViewColumnCollection ColumnCollection, string dataPropertyName)
 {
     return(ColumnCollection.Cast <DataGridViewColumn>().FirstOrDefault(c => c.DataPropertyName == dataPropertyName));
 }
Exemplo n.º 5
0
 public static IEnumerable <DataGridViewColumn> AsEnumerable(this DataGridViewColumnCollection cols)
 => cols.Cast <DataGridViewColumn>();
Exemplo n.º 6
0
 public static DataGridViewColumn GetColumnFromText(this DataGridViewColumnCollection columns, string text)
 {
     return(columns.Cast <DataGridViewColumn>().First(t => t.HeaderText == text));
 }
 public override IEnumerator <IGridColumn> GetEnumerator()
 {
     return(_base.Cast <DataGridViewColumn>().Select(GridColumn.FromNativeColumn).GetEnumerator());
 }