zoukankan      html  css  js  c++  java
  • WPF学习——制作一个简单的录入界面(1): 添加需要的控件

    程序功能:1.输入人名,根据经验年限,把输入的人进行分组显示。

                  2.可以从显示列表中删除人名

                  3.可以清空显示列表

                  4.如果没有输入人名进行添加的时候,会提示没有输入人名

                  5.如果没有选择经验,添加的时候会提示没有选择经验

    下面用WPF实现以上功能。

    为了简单实现,本文只列了两个经验年限:1.Up to 1 year  2.More than 1year

    本文需要的WPF控件有label ,TextBox ,GroupBox ,RadioButton ,ListBox ,Button ,Image。

    实现过程:1.打开VS2010

                  2.在工具栏上点击File——选择 New Project——选择Visual C# ——Windows——WPF Application——输入工程名字:MemberInputSystem(工程名可以自己更改)

                  步骤如以下两图:

                 

                   

                  3.双击MainWindow.xaml,出现以下界面

                     4.  步骤3中会看到XAML窗口,然后把Title中的MainWindow 改为Member Input System,上面的MainWindow窗体现在就会变成标题为Member Input System的窗体。

                     5.在Member Input System窗体中添加控件。

                        点击Member Input System窗体,然后点击Toolbox,选择里面的控件,再点击Member Input System窗体,控件就会添加到Member Input System窗体中。

                         如下图:

    6.1     首先在Member Input System窗体的左上角添加一个Label控件,然后在XAML窗体中,把Label控件Content属性中的“Lable”改为“Please

              input a  name:”,

    6.2    在“Please input a name:”Label控件右边添加一个TextBox控件,在XAML窗体中更改TextBox控件的Name属性,变为Name="memberName",在这

            个控件中输入名字

    6.3    在“Please input a name:”Label控件下边添加一个GroupBox控件,在XAML窗体中更改GroupBox控件的Header,Name属性,变为Header="Please

             select your experience"   ,Name="yearsExperience"

    6.4    在Member Input System窗体中添加StackPanel控件,在XAML窗体中,将StackPanel控件的属性变为<StackPanel Margin="0,0,0,0"

            Name="stackPanel1"></StackPanel>,然后把<StackPanel Margin="0,0,0,0" Name="stackPanel1"></StackPanel>放到GroupBox控件的代码

            中,变为

            <GroupBox Panel.ZIndex="1" Header="Please select your experience" Height="60" HorizontalAlignment="Left" Margin="30,65,0,0"

            Name="yearsExperience" VerticalAlignment="Top" Width="200">
                <StackPanel Margin="0,0,0,0" Name="stackPanel1">
                </StackPanel>

            </GroupBox>

    6.7   在GroupBox控件中添加两个RadioButton控件,用来选择经验年限。

            在XAML窗体中修改两个RadionButton的content属性,其中一个改为 Content="Up to 1 year" ,另一个改为Content="More than 1 year"

    6.8   在GroupBox控件右边添加一个Button控件,在XAML窗体中修改Button的content属性和name属性,改为 Content="Add" Name="addButton",这个

            Button的功能是把输入的名字添加到相应的列表中。

    6.9   在步骤6.8 Button控件右边再添加一个Button控件,在XAML窗体中修改Button的content属性和name属性,改为Content="Remove"

            Name="removeButton",这个Button控件的功能是:把列表中的名字删除

    6.10  在GroupBox控件下面添加一个Label控件,在XAML窗体中修改content属性为Content="Add to up to 1 year",这个控件的作用:存放经验年限为up to

             1 year的人

    6.11  在步骤6.10 Label控件下面添加一个ListBox控件,在XAML窗体中修改Name属性为Name="ResultUpToOne"

    6.12  在步骤6.11的ListBox控件右边添加一个Button控件,在XAML窗体中修改Button的content属性和name属性,改为Content="Clear"

             Name="clearButton" ,这个控件的功能:清除ListBox中所有的内容

    6.13  在步骤6.10 Label控件平行的右边再添加一个Label控件,在XAML窗体中修改content属性为Content="Add to more than 1 year"

    6.14  在步骤6.13 Label控件下面添加一个ListBox控件,在XAML窗体中修改Name属性为Name="ResultMoreThanOne",这个控件的作用:存放经验年限为

             more than 1 year的人

    到目前为止需要的所有控件已经添加完成,然后用C#编程实现所有控件的功能,请看:WPF学习——制作一个简单的录入界面(2):用C#编程实现所有控件的功能

  • 相关阅读:
    jvm 指令 invokedynamic
    go switch
    JVM指令 bytecode invokespecial
    babel插件开发
    go 循环依赖 循环引用 最佳实践
    go module 使用入门
    搞懂gopath golang go go项目结构
    SQL Server 工具
    SQLServer Management Studio登录框中的“服务器名”填写
    win2008下安装SQL SERVER 2005出现IIS功能要求 警告解决方案
  • 原文地址:https://www.cnblogs.com/greenteaone/p/1832750.html
Copyright © 2011-2022 走看看