C # Personnel Management system common layout and controls for the next day

Source: Internet
Author: User
Tags time and seconds

TextBox text Box

<textbox isreadonly= "true"/>//Read-only

<textbox textwrapping= "Wrap"/>/folding-Multiple lines of text

<textbox maxlength= "5"/>//MAX length

PasswordBox Password Box

<passwordbox password= "admin"/>

Nullable type (NULL): Reference type-custom class, String, most class

Non-nullable types: value types (int, boolean, decimal decimal, DateTime)

Add after a non-nullable type? Can be a null DateTime after? D1=null;

CheckBox check box control has a third state

The IsChecked property indicates whether the check box is selected and is of type bool?

if ((bool) checkbox1.ischecked)

{

MessageBox.Show ("checked");

}

RadioButton radio Button controls

Grouping: Preventing mutexes

<radiobutton groupname= "First Group"/>

DatePicker Date list (. NET4.5 later)

Gets the selected date:

Datetime? Value =datepicker1.selecteddate;

if (value==null) {}

Else{messagebox.show (value. ToString ());}

Assignment value:

datepicker1.selecteddate=datetime.today;//contains only month and day, now contains time and seconds

Image control: Picture control

<image source= "Img/1.jpg"/>

ProgressBar: Progress bar control

Isindeterminate whether the mode is indeterminate, maximum maximum value, minimum minimum value

Value Current values

probar1.value+=10;

<progressbar isindeterminate= "true"/>

Page layout

StackPanel layout

<Grid>

<stackpanel orientation= "Horizontal" >//Sub-elements portrait arrangement

<Button.Content>

<image source= "1.jpg"/>

</Button.Content>

</StackPanel>

</Grid>

<textblock verticalalignment= "center"/>//perpendicular to its way: centered

<textblock horizontalalignment= "center"/>//Horizontal centering mode

<textblock margin= "5"/>//width around the distance

Grid layout

<grod >

<Grid.ColumnDefinitions>//define two columns

<columndefinition width= "/>"

<ColumnDefinition/>

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>//define two lines

<rowdefinition height= "/>"

<RowDefinition/>

</Grid.RowDefinitons>

<button grid.row= "1" grid.column= "1"/>

<textbox background= "Red" text= "Hello" grid.column= "2" grid.row= "1" grid.columnspan= "2"/>//Occupy two columns

</Grid>

To add controls to the layout dynamically:

<stackpanel name= "SP1" mouseenter= "sq1_mouseenter/" >

In the container's Mouse move event:

button Btn1=new button (); Dynamically creating controls

Btn1. content= "New Button";

SP1. Children.add (BTN1); Adding a control to the StackPanel of the container's parent control

Automatically add a button control each time you mouse over the container

To dynamically generate rows and columns:

<grid name= "Gridgame" >

</Grid>

In the Window_Loaded event

for (int i=0;i<10;i++)

{

ColumnDefinition coldef=new columndefinition ();

GRIDGAME.COLUMNDEFINITION.ADD (COLDEF);

RowDefinition rowdef=new rowdefinition ();

GRIDGAME.ROWDEFINITION.ADD (ROWDEF);
}

for (int i=0;i<10;i++)

{

for (int j=0;j<10;j++)

{

button Btn=new button ();

Btn. content=i+ "," +J;

Grid.setrow (btn,1);//Modify the control's Grid.Row property by code

Grid.setcolumn (BTN,J);

GRIDGAME.CHILDREN.ADD (BTN);

}

}

Change the button above to a picture:

Image img=new image ();

Img. Source=new BitmapImage (New Url ("1.jpg", urlkind.relative));

Grid.setrow (Img,i);

Grid.setcolumn (IMG,J);

GRIDGAME.CHILDREN.ADD (Image);

Randomly display a picture:

Random random=new random ();

int Imgname=random. Next (1,10); Generates a >=1, <10 random number

Img. Source=new BitmapImage (New Url ("images/" +imagename+ ". jpg", urlkind.relative));

All the controls can be new

About nesting of layouts:

StackPanel and grids can be nested or nested with each other

C # Personnel Management system common layout and controls for the next day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.