• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

c#基本控件,窗口程序

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

主窗体:

using System;//基础核心命名空间
using System.Collections.Generic;
using System.ComponentModel;//组建模型
using System.Data;//数据库访问控制
using System.Drawing;//绘图
using System.Linq;
using System.Text;//文本
using System.Threading.Tasks;//线程
using System.Windows.Forms;//窗体

namespace myone//命名空间
{
    public partial class mainform : Form//窗口
    {
        public mainform()//界面
        {
            InitializeComponent();
        }
        //下面是业务逻辑、事件
        //组合框时间
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //
            string mess = comboBox1.SelectedItem.ToString();
            comboBox2.SelectedItem = mess;
            listBox1.SelectedItem = mess;
            intext1.Text = mess;



        }
        //添加信息
        private void button1_Click(object sender, EventArgs e)
        {




        }
        //退出
        private void button4_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        //  取消
        private void button3_Click(object sender, EventArgs e)
        {
            intext1.Enabled = false;
            listBox1.Enabled = false;



        }
        //确定
        private void button2_Click(object sender, EventArgs e)
        {
            intext1.Enabled = true;
            listBox1.Enabled = true;
            comboBox1.SelectedIndex = 0;
            intext1.Focus();
        }
        
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel1.LinkVisited = true;
            Form2 newForm = new Form2();
            newForm.Show();
            this.Hide();

        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            label7.Show();
        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            label7.Hide();
        }

        private void mainform_Load(object sender, EventArgs e)
        {
            this.listBox1.Items.Add("软件部");
            this.listBox1.Items.Add("硬件部");
            this.listBox1.Items.Add("财务部");
            this.listBox1.Items.Add("人事部");
            this.listBox1.SelectedIndex = 1;
           
            this.comboBox1.Items.Add("软件部");
            this.comboBox1.Items.Add("硬件部");
            this.comboBox1.Items.Add("财务部");
            this.comboBox1.Items.Add("人事部");
            this.comboBox1.SelectedIndex = 1;
            
            this.comboBox2.Items.Add("软件部");
            this.comboBox2.Items.Add("硬件部");
            this.comboBox2.Items.Add("财务部");
            this.comboBox2.Items.Add("人事部");
            this.comboBox2.SelectedIndex = 1;

            this.intext1.Text = "硬件部";

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show("您选择的部门是:"+listBox1.SelectedItem.ToString()+",位列第"+listBox1.SelectedIndex.ToString(),"信息提示");
        }
        //窗口1
        private void button5_Click(object sender, EventArgs e)
        {
            MessageBox.Show("简单提示!", "信息提示");
        }
        //窗口2
        private void button6_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("简单提示!", "信息提示",MessageBoxButtons.YesNo);
            if(result==DialogResult.Yes)
            {
                label1.Text = "您选择了图标YES";

            }
            else
            {
                label1.Text = "您选择了图标NO";


            }
        }
        //窗口3
        private void button7_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("简单提示!", "信息提示",
               MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,
               MessageBoxDefaultButton.Button3,MessageBoxOptions.RightAlign);

            if(result ==DialogResult.Yes)
            {
                label1.Text="YES";

            }

            else if(result== DialogResult.No)
            {

                 label1.Text="NO";
            }

            else if(result==DialogResult.Cancel)
            {
                 label1.Text="CANCEL";
            }
           
        }

        private void button9_Click(object sender, EventArgs e)
        {
            //mainform mf = new mainform();
            business f2 = new business();
            this.Visible = false;
            f2.ShowDialog();
          //  this.Visible = true;//
        }
    }
}

form2 :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace myone
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        //返回主对话框
        private void button1_Click(object sender, EventArgs e)
        {
            mainform firstform = new mainform();
            firstform.Show();
            this.Hide();

        }
        //返回
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //返回后,窗体信息初始化
            mainform firstform = new mainform();
            firstform.Show();
            this.Hide();
        }
        //登陆
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            business busform = new business();
            busform.Show();
            this.Hide();
        }
        private void Clear()
        {

            zhanhao.Clear();
            mima.Clear();
            zhanhao.Focus();


        }
        //登陆到主业务窗口
        private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if(zhanhao.Text == string.Empty || mima.Text == string.Empty)
            {
                MessageBox.Show("请出入登录信息!","登录出错");
                Clear();
                return;
            }
            if(!zhanhao.Text.Equals("admin")|| !mima.Text.Equals("admin"))
            {
                MessageBox.Show("用户名称和密码不正确!","登录提示");
                Clear();
                return;

            }
            else
            {
                business busform = new business();
                busform.Show();
                this.Hide();
            }


           //
            //business busform = new business();
            //busform.Show();
           // this.Hide();

        }

        private void 按钮ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}

business:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace myone
{
    public partial class business : Form
    {
        public business()
        {
            InitializeComponent();
        }

        private void 返回主界面ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainform firform = new mainform();
            firform.Show();
            this.Hide();
        }
    }
}

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#/VB.NET在Word转PDF时生成目录书签发布时间:2022-07-10
下一篇:
温故而知新C#分支与循环发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap