Tema: Re: C# keyprees nustatymas???
Autorius: Dziedukas
Data: 2012-05-21 14:49:12
kazko nedaro, i textbox'a pereina automatiskai is kito textbox'o ir tik 
uzejus is karto meta nustatyta message (antras). teks deti ant mygtuko, 
kuris duomenis apdirba, kad tikrintu ar textboxe esantis skaicius yra 
mazesnis uz masyvo ilgi ir bus paprasciau.
>        int maxSize = 5;
>        private void textBox1_KeyUp(object sender, KeyEventArgs e)
>        {
>            int myInt = 0;
>            bool rez = Int32.TryParse(textBox1.Text, out myInt);
>            if (rez)
>            {
>                if (myInt > maxSize)
>                {
>                    SetText("");        //cia padares 
> MessageBox.Show("Klaida.....");
>                }
>            }
>            else
>            {
>                // unable to convert string to integer.
>                SetText("");         //cia padares MessageBox.Show("Kitas 
> pranesimas.....");
>            }
>            e.Handled = true;
>        }
>
>        delegate void SetTextCallback(String textToSet);
>        private void SetText(String textToSet)
>        {
>            if (textBox1.InvokeRequired)
>            {
>                SetTextCallback d = new SetTextCallback(SetText);
>                this.Invoke(d, new object[] { textToSet });
>            }
>            else
>            {
>                textBox1.Text = textToSet;
>            }
>        }
>
>