Beispiel #1
0
        public ListViewEx()
        {
            Items         = new LVIC_Ex(this);
            FullRowSelect = true;

            //Activate double buffering
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);

            //Enable the OnNotifyMessage event so we get a chance to filter out
            // Windows messages before they get to the form's WndProc
            SetStyle(ControlStyles.EnableNotifyMessage, true);

            //fillLast();
            //SizeChanged += (a, b) => fillLast();
            TabStop      = false;
            FontChanged += ListViewEx_FontChanged;

            //
            // editor
            //
            editor                  = new AutoTextBox();
            editor.Visible          = false;
            editor.BorderStyle      = BorderStyle.None;
            editor.Margin           = new Padding(0);
            editor.Multiline        = true;
            editor.AcceptsReturn    = false;
            editor.TabStop          = false;
            editor.Leave           += editor_Leave;
            editor.PreviewKeyDown  += editor_PreviewKeyDown;
            editor.KeyDown         += editor_KeyDown;
            editor.TextTransformer += editor_TextTransformer;
        }
Beispiel #2
0
        void selectiveNumber(Regex allowed, AutoTextBox from, StringBuilder text, ref int caret)
        {
            bool one = false;
            char c;
            int  i;

            if (keyDel == false)
            {
                text.Remove(0, caret);
                caret = 0;
            }
            else if (keyDel == true)
            {
                text.Remove(caret, text.Length - caret);
                caret = text.Length;
            }
            keyDel = null;
            for (i = 0; i < text.Length; i++)
            {
                one = true;
                c   = text[i];
                if (!allowed.Match(c + "").Success)
                {
                    text.Remove(i, 1);
                    i--;
                }
            }
            if (!one)
            {
                text.Append(0);
                caret = 1;
            }
            bool?moreTrail = null;

            for (i = 0; i < text.Length - 1 && moreTrail != false; i++)
            {
                c = text[i];
                if ((moreTrail = c == '0').Value)
                {
                    text.Remove(i, 1);
                    i--;
                }
            }
            if (Core.TryChangeType(text.ToString(), TypeCode.Decimal, out decimal r))
            {
                if (r > numMax)
                {
                    text.Clear();
                    text.Append(numMax);
                }
                else if (r < numMin)
                {
                    text.Clear();
                    text.Append(numMin);
                }
            }
            if (managedKey)
            {
                caret = text.Length;
            }
        }
Beispiel #3
0
 void editor_TextTransformer(AutoTextBox from, StringBuilder text, ref int caret)
 => editorTransformer?.Invoke(from, text, ref caret);