Exemplo n.º 1
0
        private void AddItem2ComboBox(RadComboBoxElement cbb, CSDataRow dr)
        {
            DataTable dt = dr.EmbeddedCtlPara.ComBoCtlDataSource;

            if (cbb.GetType().Equals(typeof(RadComboBoxElement)))
            {
                cbb.ValueChanged -= ctlComboBoxElement_ValueChanged;
                cbb.SelectedIndex = -1;
                cbb.DataSource    = dt;
                cbb.DisplayMember = dr.EmbeddedCtlPara.DisplayMember;
                cbb.ValueMember   = dr.EmbeddedCtlPara.ValueMember;
                cbb.ValueChanged += new EventHandler(ctlComboBoxElement_ValueChanged);
            }
            else if (cbb.GetType().Equals(typeof(CSCheckComboBoxElement)))
            {
                CSCheckComboBoxElement chkcbb = cbb as CSCheckComboBoxElement;
                chkcbb.Items.Clear();
                foreach (DataRow row in dt.Rows)
                {
                    chkcbb.AddItem(row["LocalName"].ToString());
                }
            }
            else if (cbb.GetType().Equals(typeof(CSComboBoxExxElement)))
            {
                cbb.ValueChanged -= ctlComboBoxExxElement_ValueChanged;
                cbb.SelectedIndex = -1;
                cbb.DataSource    = dt;
                cbb.DisplayMember = dr.EmbeddedCtlPara.DisplayMember;
                cbb.ValueMember   = dr.EmbeddedCtlPara.ValueMember;
                cbb.ValueChanged += ctlComboBoxExxElement_ValueChanged;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add a new CSDataRow which contains embedded checkcombobox
        /// </summary>
        /// <param name="dataSource">checkcombobox data source</param>
        /// <returns></returns>
        public CSDataRow NewCheckComboBoxRow(DataTable dataSource)
        {
            CSDataRow dr = NewRow(EmbedControlType.CheckComboBox);

            dr.EmbeddedCtlPara.ComBoCtlDataSource = dataSource;
            return(dr);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a new CSDataRow which contains embedded control type info
        /// </summary>
        /// <param name="ctlType">embedded control type</param>
        /// <returns></returns>
        public CSDataRow NewRow(EmbedControlType ctlType)
        {
            CSDataRow dr = this.NewRow() as CSDataRow;

            dr.Tag = ctlType;
            this.Rows.Add(dr);
            return(dr);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add a new CSDataRow which contains embedded combobox
        /// </summary>
        /// <param name="dataSource">combobox data source</param>
        /// <param name="valueMember">combobox value member</param>
        /// <param name="displayMember">combobox display member</param>
        /// <returns></returns>
        public CSDataRow NewComboBoxExxRow(DataTable dataSource, string valueMember, string displayMember)
        {
            CSDataRow dr = NewRow(EmbedControlType.CSComboBoxExx);

            dr.EmbeddedCtlPara.ComBoCtlDataSource = dataSource;
            dr.EmbeddedCtlPara.DisplayMember      = displayMember;
            dr.EmbeddedCtlPara.ValueMember        = valueMember;
            return(dr);
        }
Exemplo n.º 5
0
        public override void SetContent()
        {
            CSDataRow dr = (RowInfo.DataBoundItem as DataRowView).Row as CSDataRow;

            dr.EmbeddedCtlPara.CtlCell = this;
            if (dr == null)
            {
                base.SetContent();
                return;
            }
            EmbedControlType ctlType = (EmbedControlType)dr.Tag;

            switch (ctlType)
            {
            case  EmbedControlType.CheckBox:
                UpdateVisibility(ctlChk);
                object value = this.Value;
                if (value == null || value == DBNull.Value || bool.FalseString.Equals(value.ToString()))
                {
                    ctlChk.ToggleState = ToggleState.Off;
                }
                else
                {
                    ctlChk.ToggleState = ToggleState.On;
                }
                break;

            case  EmbedControlType.CheckComboBox:
                AddItem2ComboBox(ctlCheckComboBoxElement, dr);
                UpdateVisibility(ctlCheckComboBoxElement);
                ctlCheckComboBoxElement.CheckedNames = this.Value.ToString();
                break;

            case EmbedControlType.CSComboBoxExx:
                AddItem2ComboBox(ctlComboBoxExxElement, dr);
                UpdateVisibility(ctlComboBoxExxElement);
                bool hasValue1 = false;
                foreach (RadItem item in ctlComboBoxExxElement.Items)
                {
                    if (item.Text.Equals(this.Value))
                    {
                        ctlComboBoxExxElement.SelectedItem = item;
                        if (ctlComboBoxExxElement.IsPopupOpen)
                        {
                            ctlComboBoxExxElement.ListBoxElement.Focus();
                        }
                        hasValue1 = true;
                        break;
                    }
                }
                if (!hasValue1)
                {
                    ctlComboBoxExxElement.SelectedIndex = -1;
                }
                break;

            case  EmbedControlType.ComboBox:
                AddItem2ComboBox(ctlComboBoxElement, dr);
                UpdateVisibility(ctlComboBoxElement);
                bool hasValue = false;
                foreach (RadItem item in ctlComboBoxElement.Items)
                {
                    if (item.Text.Equals(this.Value))
                    {
                        ctlComboBoxElement.SelectedItem = item;
                        hasValue = true;
                        break;
                    }
                }
                if (!hasValue)
                {
                    ctlComboBoxElement.SelectedIndex = -1;
                }
                break;

            case EmbedControlType.TextBox:
                UpdateVisibility(ctlTextBox);
                ctlTextBox.Text = this.Value.ToString();
                break;

            case EmbedControlType.DateTimePicker:
                UpdateVisibility(ctlDataTimePickerElement);
                DateTime dt = DateTime.Now;
                DateTime.TryParse(this.Value.ToString(), out dt);
                ctlDataTimePickerElement.Value = dt;
                break;

            case EmbedControlType.ColorSelector:
                UpdateVisibility(ctlTextBox);
                ctlColorSelectorElement.Value = this.Value;
                break;

            case EmbedControlType.Spin:
                UpdateVisibility(ctlSpin);
                decimal result = 0;
                if (decimal.TryParse(this.Value.ToString(), out result))
                {
                    ctlSpin.Value = decimal.Parse(this.Value.ToString());
                }
                else
                {
                    ctlSpin.Value = 0;
                }
                break;

            case EmbedControlType.CSNumericTextBox:
                UpdateVisibility(ctlNumericTextBox);
                ctlNumericTextBox.Text = this.Value.ToString();
                break;

            case EmbedControlType.CSIntTextBox:
                UpdateVisibility(ctlIntTextBox);
                ctlIntTextBox.Text = this.Value.ToString();
                break;
            }
        }
Exemplo n.º 6
0
        public CSDataRow NewIntegerRow()
        {
            CSDataRow dr = NewRow(EmbedControlType.CSIntTextBox);

            return(dr);
        }
Exemplo n.º 7
0
        public CSDataRow NewNumericRow()
        {
            CSDataRow dr = NewRow(EmbedControlType.CSNumericTextBox);

            return(dr);
        }
Exemplo n.º 8
0
        public CSDataRow NewSpinRow()
        {
            CSDataRow dr = NewRow(EmbedControlType.Spin);

            return(dr);
        }