Ejemplo n.º 1
0
        private void InitializeAutoCompleteSource()
        {
            if (base.AutoCompleteCustomSource != null)
            {
                AutoCompleteStringCollection _customsource = base.AutoCompleteCustomSource;
                if (_customsource == null)
                {
                    _customsource = new AutoCompleteStringCollection();
                }

                _customsource.Clear();
                if (DataSource != null)
                {
                    if (!String.IsNullOrEmpty(DisplayMember.RLTrim()))
                    {
                        if (DataSource.Columns.Contains(DisplayMember))
                        {
                            DataView  _view  = DataSource.DefaultView;
                            DataTable _table = _view.ToTable();
                            _table.DefaultView.Sort = "[" + DisplayMember + "]";
                            DataView  _viewsorted  = _table.DefaultView;
                            DataTable _tablesorted = _viewsorted.ToTable();

                            foreach (DataRow rw in _tablesorted.Rows)
                            {
                                string _text = "";
                                if (!Materia.IsNullOrNothing(rw[DisplayMember]))
                                {
                                    _text = rw[DisplayMember].ToString();
                                }
                                if (!_customsource.Contains(_text))
                                {
                                    _customsource.Add(_text);
                                }
                            }

                            _tablesorted.Dispose();  _table.Dispose();
                            _tablesorted = null; _table = null;
                            Materia.RefreshAndManageCurrentProcess();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void DataSourcedComboBox_TextChanged(object sender, EventArgs e)
        {
            if (!_detectinput)
            {
                return;
            }
            if (DataSource != null)
            {
                if (!string.IsNullOrEmpty(DisplayMember.RLTrim()))
                {
                    if (DataSource.Columns.Contains(DisplayMember))
                    {
                        DataTable _viewtable = DataSource.DefaultView.ToTable();
                        DataRow[] rws        = _viewtable.Select("CONVERT([" + DisplayMember + "], System.String) LIKE '" + Text.ToSqlValidString(true) + "'");
                        if (rws.Length > 0)
                        {
                            if (!string.IsNullOrEmpty(ValueMember.RLTrim()))
                            {
                                if (DataSource.Columns.Contains(ValueMember))
                                {
                                    C1FlexGrid _grid  = _dropdown.Grid;
                                    int        _index = _grid.FindRow(rws[0][ValueMember], _grid.Rows.Fixed, _grid.Cols.Fixed, false) - 1;
                                    _selectedindex = (_index < 0 ? -1 : _index);
                                    OnSelectedIndexChanged(new EventArgs());
                                    _selectedvalue = rws[0][ValueMember];
                                    OnSelectedValueChanged(new EventArgs());
                                }
                                else
                                {
                                    bool _changed = false;
                                    _changed       = (_selectedindex != -1);
                                    _selectedindex = -1;
                                    if (_changed)
                                    {
                                        OnSelectedIndexChanged(new EventArgs());
                                    }

                                    _changed       = (_selectedvalue != null);
                                    _selectedvalue = null;
                                    if (_changed)
                                    {
                                        OnSelectedValueChanged(new EventArgs());
                                    }
                                }
                            }
                            else
                            {
                                bool _changed = false;
                                _changed       = (_selectedindex != -1);
                                _selectedindex = -1;
                                if (_changed)
                                {
                                    OnSelectedIndexChanged(new EventArgs());
                                }

                                _changed       = (_selectedvalue != null);
                                _selectedvalue = null;
                                if (_changed)
                                {
                                    OnSelectedValueChanged(new EventArgs());
                                }
                            }
                        }
                        else
                        {
                            bool _changed = false;
                            _changed       = (_selectedindex != -1);
                            _selectedindex = -1;
                            if (_changed)
                            {
                                OnSelectedIndexChanged(new EventArgs());
                            }

                            _changed       = (_selectedvalue != null);
                            _selectedvalue = null;
                            if (_changed)
                            {
                                OnSelectedValueChanged(new EventArgs());
                            }
                        }
                        _viewtable.Dispose(); _viewtable = null;
                        Materia.RefreshAndManageCurrentProcess();
                    }
                    else
                    {
                        bool _changed = false;
                        _changed       = (_selectedindex != -1);
                        _selectedindex = -1;
                        if (_changed)
                        {
                            OnSelectedIndexChanged(new EventArgs());
                        }

                        _changed       = (_selectedvalue != null);
                        _selectedvalue = null;
                        if (_changed)
                        {
                            OnSelectedValueChanged(new EventArgs());
                        }
                    }
                }
                else
                {
                    bool _changed = false;
                    _changed       = (_selectedindex != -1);
                    _selectedindex = -1;
                    if (_changed)
                    {
                        OnSelectedIndexChanged(new EventArgs());
                    }

                    _changed       = (_selectedvalue != null);
                    _selectedvalue = null;
                    if (_changed)
                    {
                        OnSelectedValueChanged(new EventArgs());
                    }
                }
            }
            else
            {
                bool _changed = false;
                _changed       = (_selectedindex != -1);
                _selectedindex = -1;
                if (_changed)
                {
                    OnSelectedIndexChanged(new EventArgs());
                }

                _changed       = (_selectedvalue != null);
                _selectedvalue = null;
                if (_changed)
                {
                    OnSelectedValueChanged(new EventArgs());
                }
            }
        }