zoukankan      html  css  js  c++  java
  • Win form碎知识点

    窗体位于屏幕中心 strtposition
    form前提下 acceptbutton canclebutton
    Tabindex table键 不需要的设为0
    MaximizeBox--false 最大框禁用
    panle radiobutton 年级GropDownList
    groupBox 容器 panl 面板 radiobutton放在Panle中,实现单选互斥
    菜单项 toolstrip menustrip
    menustrip一用于左上角,如文件,编辑...之类的;
    ContextMenuStrip是你单击出来修改,删除,这样之类的
    
    !!!!!!!!!!!!!!!ToolStrip 介个控件很实用,很实用!!!!!!!!!!!!!!!!!!!
    DataTable dt = NewsBLL.GetNewsType();
    DropDownList1.DataValueField = "NewID";
    DropDownList1.DataTextField = "NewName";
    DropDownList1.DataSource = dt;
    DropDownList1.DataBind();
    下拉框展示
    public void GetGrade() { Grade Gd = new Grade(); GrideList.ValueMember = "ID"; DataValueFiled = "ID"; GrideList.DisplayMember = "name"; DataTextField = "name"; selectText = name selectvalue = ID }
    DataTable dt = TransBLL.ComBoxBLL.GetProList();
    comboBox1.DataSource = dt;
    DataRow dr = dt.NewRow();
    dr["ProvinceName"] = "请选择";
    dt.Rows.InsertAt(dr, 0);
    comboBox1.ValueMember = "ProvinceName";
    comboBox1.SelectedIndex = 0;

    ———————————

    给DataGrview添加事件

    selectionMode的值变成FullRowSelect
    private void dataGridView1_Click(object sender, EventArgs e)
    {
    this.tBoxName.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
    this.tBoxGoodsStyle.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();

    }

    //获取点击行的ID

    int ID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
    GG.GoodsID = ID;
    int result = SaleBLL.GoodsMangerBLL.Update(GG);
    要想出现那个删除的按钮,就是在控件中添加contextMenuStrip控件
    !!!!!!!!!!!!
    
    在datadriview中有一个contextMenuStrip属性,值指向contextMenuStrip1
    private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
    {}

    由主窗体跳转到子窗体的时候,主窗体有一个ISMdiContainer属性设置为TRUE;!!!!!!!!!!!!!!!!!!

    private void 添加货物ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if(!ShowChildrenForm("AddGoods"))
        {
            AddGoods AG = new AddGoods(); //将要打开的窗体实例化
            AG.MdiParent = this; //要子窗体的父窗体设置为当前窗体
            AG.Show();
        }
    }

    /// <summary>

    /// 防止子窗体重复出现
    /// </summary>
    /// <param name="ChildFormName">把子窗体的name传递过来</param>
    /// <returns></returns>

    private bool ShowChildrenForm(string ChildFormName)
    {
        int i;
        for(i = 0; i < this.MdiChildren.Length; i++)
        {
            //判断子窗体是否已经打开
            if(this.MdiChildren[i].Name == ChildFormName)
            {
                //如果子窗体已经打开,设置子窗体位焦点
                this.MdiChildren[i].Activate();
                return true;
            }
        }
        return false;
    }

    弹出框的确定 取消

    DialogResult dr = MessageBox.Show("确定要删除吗?", "删除", MessageBoxButtons.YesNoCancel);
    if(dr == DialogResult.Yes)
    {}
    else
    {
        return;
    }
    int ID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

    ///选择dataGriview里的一行,传到修改里去,前提dataGriview的selectMode属性变成一行

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void dataGridView1_Click(object sender, EventArgs e)
    {
        this.tBoxBar.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
        this.tBoxName.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
        this.tBoxSize.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
        this.CmbStyle.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
        this.tBoxBuyIn.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
        this.tBoxPiFa.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
        this.tBoxLPrice.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
        this.tBoxCurNum.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
        this.tBoxNote.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
        this.tBoxProduct.Text = dataGridView1.SelectedRows[0].Cells[10].Value.ToString();
    }

    ------------------------------------------------字符串分割----------------------------------------------------------------------

    private void button2_Click(object sender, EventArgs e)
    {
        //循环输出所有字符
        string txtinput = textBox1.Text.Trim();
        foreach(char item in txtinput)
        {
            //MessageBox.Show(item.ToString());
        }
        for(int i = 0; i < txtinput.Length; i++)
        {
            MessageBox.Show(txtinput[i].ToString());
        }
    }
    private void button1_Click(object sender, EventArgs e)
    {
        string txtinput = textBox1.Text.Trim();
        string[] str = txtinput.Split(','); //按照特定的符号进行分割
        foreach(string item in str)
        {
            // MessageBox.Show(item.ToString());
        }
        for(int i = 0; i < str.Length; i++)
        {
            MessageBox.Show(str[i]);
        }
    }
  • 相关阅读:
    网页如何展示PPT文档
    关于DLL中Resources文件修改
    解決 IE10 浏览器无法使用 ASP.NET From 验证登录的问题
    Ubuntu 13.10 下安装 eclipse
    Ubuntu 13.10 下安装node
    关于AutoCAD.NET的辅助方法
    Linux下安装oracle11g
    Linux下配置VNC
    Linux下安装McAfee防病毒软件(企业版本)
    .net 下word 中的图片与文字分离
  • 原文地址:https://www.cnblogs.com/ZkbFighting/p/8145648.html
Copyright © 2011-2022 走看看