17-10-12, 05:19 PM
كاتب الموضوع : AhmedEssawy
مثال كامل ... يتطرق للعديد من خواصه ... مدعوم بكومنتvb.net
كود :
[color=blue]Public[/color] [color=blue]Sub[/color] InstantiateMyNumericUpDown()
[color=green]' Create and initialize a NumericUpDown control.[/color]
numericUpDown1 = [color=blue]New[/color] NumericUpDown()
[color=green]' Dock the control to the top of the form.[/color]
numericUpDown1.Dock = System.Windows.Forms.DockStyle.Top
[color=green]' Set the Minimum, Maximum, and initial Value.[/color]
numericUpDown1.Value = 5
numericUpDown1.Maximum = 2500
numericUpDown1.Minimum = - 100
[color=green]' Add the NumericUpDown to the Form.[/color]
Controls.Add(numericUpDown1)
[color=blue]End[/color] [color=blue]Sub[/color]
[color=green]' Check box to toggle decimal places to be displayed.[/color]
[color=blue]Private[/color] [color=blue]Sub[/color] checkBox1_Click(sender [color=blue]As[/color] [color=blue]Object[/color], e [color=blue]As[/color] EventArgs)
[color=green]' If DecimalPlaces is greater than 0, set them to 0 and round the[/color]
[color=green]' current Value; otherwise, set DecimalPlaces to 2 and change the[/color]
[color=green]' Increment to 0.25. [/color]
[color=blue]If[/color] numericUpDown1.DecimalPlaces > 0 [color=blue]Then[/color]
numericUpDown1.DecimalPlaces = 0
numericUpDown1.Value = [color=blue]Decimal[/color].Round(numericUpDown1.Value, 0)
[color=blue]Else[/color]
numericUpDown1.DecimalPlaces = 2
numericUpDown1.Increment = 0.25D
[color=blue]End[/color] [color=blue]If[/color]
[color=blue]End[/color] [color=blue]Sub[/color]
[color=green]' Check box to toggle thousands separators to be displayed.[/color]
[color=blue]Private[/color] [color=blue]Sub[/color] checkBox2_Click(sender [color=blue]As[/color] [color=blue]Object[/color], e [color=blue]As[/color] EventArgs)
[color=green]' If ThousandsSeparator is true, set it to false;[/color]
[color=green]' otherwise, set it to true. [/color]
[color=blue]If[/color] numericUpDown1.ThousandsSeparator [color=blue]Then[/color]
numericUpDown1.ThousandsSeparator = [color=blue]False[/color]
[color=blue]Else[/color]
numericUpDown1.ThousandsSeparator = [color=blue]True[/color]
[color=blue]End[/color] [color=blue]If[/color]
[color=blue]End[/color] [color=blue]Sub[/color]
[color=green]' Check box to toggle hexadecimal to be displayed.[/color]
[color=blue]Private[/color] [color=blue]Sub[/color] checkBox3_Click(sender [color=blue]As[/color] [color=blue]Object[/color], e [color=blue]As[/color] EventArgs)
[color=green]' If Hexadecimal is true, set it to false;[/color]
[color=green]' otherwise, set it to true. [/color]
[color=blue]If[/color] numericUpDown1.Hexadecimal [color=blue]Then[/color]
numericUpDown1.Hexadecimal = [color=blue]False[/color]
[color=blue]Else[/color]
numericUpDown1.Hexadecimal = [color=blue]True[/color]
[color=blue]End[/color] [color=blue]If[/color]
[color=blue]End[/color] [color=blue]Sub[/color]