Example #1
0
        //Défini si c'est le control d'édition ou le DataGridView qui doit traiter la touche
        //retourne vrai si la touche doit être gérer par le control
        //Bizarement le Enter est tout de même traité par le DGV
        public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
        {
            TextBox          txtBox         = null;
            CTextBoxZoomable txtBoxZoomable = null;

            if (m_mode == ModeFonctionnement.Texte)
            {
                txtBoxZoomable = m_textBox;
            }
            if (m_mode == ModeFonctionnement.Decimal ||
                m_mode == ModeFonctionnement.Entier)
            {
                txtBox = m_textBoxNumerique;
            }

            switch (keyData)
            {
            case Keys.Escape:
                return(false);

            case Keys.Up:
            case Keys.Down:
                if (m_mode == ModeFonctionnement.Entier ||
                    m_mode == ModeFonctionnement.Decimal ||
                    m_mode == ModeFonctionnement.Texte)
                {
                    return(false);
                }
                return(true);

            case Keys.Right:
                if (txtBox != null && txtBox.SelectionStart == txtBox.Text.Length)
                {
                    return(false);
                }
                if (txtBoxZoomable != null && txtBoxZoomable.SelectionStart == txtBoxZoomable.Text.Length)
                {
                    return(false);
                }
                if (m_mode == ModeFonctionnement.Bool)
                {
                    return(false);
                }
                return(true);

            case Keys.Left:
                if (txtBox != null && txtBox.SelectionStart == 0 && txtBox.SelectionLength == 0)
                {
                    return(false);
                }
                if (txtBoxZoomable != null && txtBoxZoomable.SelectionStart == 0 && txtBoxZoomable.SelectionLength == 0)
                {
                    return(false);
                }
                if (m_mode == ModeFonctionnement.Bool)
                {
                    return(false);
                }
                return(true);

            default:
                return(true);
            }
        }
Example #2
0
        private bool InitControl()
        {
            try
            {
                for (int i = Controls.Count; i > 0; i--)
                {
                    Controls[i - 1].Dispose();
                }

                Control ctrl = null;
                switch (m_mode)
                {
                case ModeFonctionnement.Texte:
                    m_textBox              = new CTextBoxZoomable();
                    m_textBox.Text         = DefaultValueSelonType.ToString();
                    m_textBox.KeyDown     += new KeyEventHandler(m_textBox_KeyDown);
                    m_textBox.TextChanged += new EventHandler(m_control_ValueChanged);
                    ctrl = m_textBox;
                    break;

                case ModeFonctionnement.Entier:
                case ModeFonctionnement.Decimal:
                    m_textBoxNumerique = new C2iTextBoxNumerique();
                    m_textBoxNumerique.NullAutorise     = true;
                    m_textBoxNumerique.SelectAllOnEnter = true;
                    m_textBoxNumerique.DecimalAutorise  = (m_mode == ModeFonctionnement.Decimal);
                    if (m_mode == ModeFonctionnement.Decimal)
                    {
                        m_textBoxNumerique.Arrondi = 8;
                    }
                    else
                    {
                        m_textBoxNumerique.Arrondi = 0;
                    }
                    m_textBoxNumerique.TextChanged += new EventHandler(m_control_ValueChanged);
                    ctrl = m_textBoxNumerique;

                    break;

                case ModeFonctionnement.Date:
                    m_dateTimePicker               = new DateTimePicker();
                    m_dateTimePicker.Format        = DateTimePickerFormat.Short;
                    m_dateTimePicker.Value         = (DateTime)DefaultValueSelonType;
                    m_dateTimePicker.ValueChanged += new EventHandler(m_control_ValueChanged);
                    ctrl = m_dateTimePicker;
                    break;

                case ModeFonctionnement.Bool:
                    m_cmbBool = new ComboBox();
                    m_cmbBool.DropDownStyle = ComboBoxStyle.DropDownList;
                    m_cmbBool.Items.Add(I.T("Is Null|96"));
                    m_cmbBool.Items.Add(m_strTextFalse);
                    m_cmbBool.Items.Add(m_strTextTrue);
                    m_cmbBool.SelectedIndexChanged += new EventHandler(m_control_ValueChanged);
                    m_cmbBool.SelectedIndex         = 0;
                    ctrl = m_cmbBool;
                    break;

                default:
                    break;
                }


                Controls.Add(ctrl);
                ctrl.Dock = DockStyle.Fill;
                ctrl.BringToFront();
                return(true);
            }
            catch
            {
                return(false);
            }
        }