Exemplo n.º 1
0
        public static List<string> GetDataSource(DataGridView dgv, string columnName)
        {
            if (dgv == null)
                return null;

            List<string> list = new List<string>();

            foreach (DataGridViewRow row in dgv.Rows)
            {
                string value = row.Cells[columnName].Value.ToString();

                string endColumnHeader = columnName.Substring(columnName.Length - 3, 3);

                if ((endColumnHeader == "руб") || (value.Trim() == string.Empty))
                    continue;

                if (IsDate(value))
                {
                    MyDateTime myDate = new MyDateTime(value);
                    value = myDate.ToString();
                }

                if ((row.Visible) && (!IsInList(list, value)))
                    list.Add(value);
            }

            DataTable dt = new DataTable();
            dt.Columns.Add("Название");

            list.Sort();

            if (list.Count > 0)
                list.Insert(0, "(все)");

            return list;
        }
Exemplo n.º 2
0
        public void SetFilterValue(string columnName, Point point)
        {
            int i = -1;
            for (i = 0; i < labelList.Count; i++)
            {
                if (labelList[i].Text == columnName)
                    break;
            }

            if (i >= comboList.Count)
                return;

            string value = _dgv.Rows[point.Y].Cells[point.X].Value.ToString();

            foreach (CheckBoxComboBoxItem item in comboList[i].CheckBoxItems)
            {
                if (MyDateTime.IsDate(value))
                {
                    MyDateTime myDate = new MyDateTime(value);
                    value = myDate.ToString();
                }

                if (item.Text == value)
                {
                    item.Checked = true;
                    break;
                }
            }

            ApplyFilter();
        }
Exemplo n.º 3
0
        private void changeVisibleByFilter()
        {
            saveFilterValue();

            SetVisibleAllRows();

            _dgv.CurrentCell = null;
            bool filtersNotSet = true;

            for (int comboIndex = 0; comboIndex < comboList.Count; comboIndex++)
            {
                if (IsFilterEmpty(comboIndex))
                    continue;

                filtersNotSet = false;

                if (!IsAllSelected(comboIndex))
                {
                    foreach (DataGridViewRow row in _dgv.Rows)
                    {
                        string dgvValue = row.Cells[comboList[comboIndex].Name].Value.ToString();
                        if (MyDateTime.IsDate(dgvValue))
                        {
                            MyDateTime myDate = new MyDateTime(dgvValue);
                            dgvValue = myDate.ToString();
                        }

                        row.Visible = ((IsEqualsFilterValue(comboIndex, dgvValue)) && (row.Visible == true));
                    }
                }
            }

            if (filtersNotSet)
                SetVisibleAllRows();
        }