zoukankan      html  css  js  c++  java
  • winform-菜单工具栏--容器(listview)

    -----------------记事本-----------------------------

    textBox 中 --外观---ScrollBars--Vertical(垂直滚动条)

    textBox ---属性更改------TextChanged----()

    --------------------------------------

    this.Close(); //关闭窗口

    textBox1.Undo(); //撤销textBox1中的上一个操作

    textBox1.Cut(); //剪切--将textBox1中所选内容移动到剪切板中

    textBox1.Copy(); //复制--将textBox1中所选内容复制到剪切板中

    textBox1.Paste(); //粘贴--用剪切板中的内容替换textBox1中所选内容

    textBox1.SelectAll(); //选择textBox1中全部内容
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
    string num = textBox1.TextLength.ToString(); //textBox1中的字数
    zishu.Text = num; //字数显示
    }

    -------------------------------------

    --------------菜单和工具栏--------------------------------

    ContextMenuStrip---------右键菜单栏
    MenuStrip------------顶部菜单栏
    statusStrip----------底部菜单栏
    ToolStrip------------工具栏
    ToolStripContainer-----(四周可以放置 菜单、控件)

    ---------容器------------------------------


    FlowLayoutPanel--------(内部控件)流式布局

    GroupBox----------控件分组 有边框、标题

    ----
    Panel-----------控件分组 无边框、标题

    ---
    SplitContainer-----就是两个Panel

    ---

    TabControl--------带标签的选项卡

    ---
    TableLayoutPanel---------类似表格 一格只能放一个控件


    --------LisView控件-------------------------------------
    类似一个表 
    可显示数据库内容

     1 {
     2     class student
     3     {
     4         public string _code { get; set; }
     5         public string _name { get; set; }
     6         public bool _sex { get; set; }
     7         public DateTime _bithday { get; set; }
     8         public decimal _score { get; set; }
     9 
    10     }
    11 }
    12 
    13 
    14  
    15 
    16 
    17 
    18 namespace WindowsFormsApplication7
    19 {
    20     public partial class Form1 : Form
    21     {
    22         SqlConnection conn = null;
    23         SqlCommand cmd = null;
    24         public Form1()
    25         {
    26             InitializeComponent();
    27             conn = new SqlConnection("server=.;database=data0425;user=sa;pwd=123;");
    28             cmd = conn.CreateCommand();
    29         }
    30 
    31         private void listView1_SelectedIndexChanged(object sender, EventArgs e)
    32         {
    33             
    34  
    35         }
    36 
    37         private void button1_Click(object sender, EventArgs e)
    38         {
    39             List<student> list = new List<student>();
    40             cmd.CommandText = "select * from student";
    41             conn.Open();
    42             SqlDataReader dr = cmd.ExecuteReader();
    43             if(dr.HasRows)
    44             {
    45                 while(dr.Read())
    46                 {
    47                     student s = new student();
    48                     s._code = dr[0].ToString();
    49                     s._name = dr[1].ToString();
    50                     s._sex = Convert.ToBoolean(dr[2]);
    51                     s._bithday = Convert.ToDateTime(dr[3]);
    52                     s._score = Convert.ToDecimal(dr[4]);
    53 
    54                     list.Add(s);
    55 
    56                 }
    57             }
    58 
    59             conn.Close();
    60 
    61             foreach(student a in list)
    62             {
    63                 ListViewItem li = new ListViewItem();
    64                 li.Text = a._code;
    65 
    66                 li.SubItems.Add(a._name);
    67                 li.SubItems.Add((a._sex ? "" : ""));
    68                 li.SubItems.Add(a._bithday.ToString("yyyy年MM月dd日"));
    69                 li.SubItems.Add(a._score.ToString());
    70 
    71                 listView1.Items.Add(li);
    72             }
    73 
    74         }
    75     }
    76 }

  • 相关阅读:
    Working with macro signatures
    Reset and Clear Recent Items and Frequent Places in Windows 10
    git分支演示
    The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1.
    Build website project by roslyn through devenv.com
    Configure environment variables for different tools in jenkins
    NUnit Console Command Line
    Code Coverage and Unit Test in SonarQube
    头脑王者 物理化学生物
    头脑王者 常识,饮食
  • 原文地址:https://www.cnblogs.com/tonyhere/p/5650462.html
Copyright © 2011-2022 走看看