示例#1
0
        //键盘事件ctrl+c和ctrl+v和ctrl+x和delete
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            //ctrl+c
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.C)
            {
                Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
            }

            //ctrl+x
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.X)
            {
                Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
                //this.dataGridView1.CurrentCell = null;
                DgvCtrl.clearSelectCell(this.dataGridView1);
            }


            //ctrl+v
            if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.V)
            {
                DgvCtrl.pasteToDataGridView(this.dataGridView1);
            }

            //delete
            if (e.KeyCode == Keys.Delete)
            {
                DgvCtrl.clearSelectCell(this.dataGridView1);
            }
        }
示例#2
0
        //单击内置模板会载入内置模板
        private void cmbTpl_SelectedIndexChanged(object sender, EventArgs e)
        {
            string tpl_name = this.cmbTpl.Text;//.SelectedIndex. >= 2)

            //如果是自定义模板,则啥也不管
            if (this.cmbTpl.SelectedIndex == 0)
            {
                return;
            }

            //实例化内置模板类
            InnerTpl form_inner_tpl = new InnerTpl();

            //MessageBox.Show(tpl_name);
            //获取模板内容
            Info[,] tpl = form_inner_tpl.getTplByName(tpl_name);


            //先初始化模板-重置所有方格
            DgvCtrl.clearAllCells(this.dataGridView0, this.dataGridView1);


            //中间信息写到界面上
            DataReadWrite.readIntoUI(tpl, this.dataGridView0, this.dataGridView1);
        }
示例#3
0
        //设置模板:要注意对用户数据的验证过滤
        private void btnAsign_Click(object sender, EventArgs e)
        {
            //如果没有选择文本框,报错
            // int i=dataGridView1.SelectedRows.Count; //选择的行数。
            if (this.dataGridView0.SelectedCells.Count == 0)
            {
                MessageBox.Show("请先在左侧模板中选择一个孔。", "系统提示");
                return;
            }


            //如果是标准品/质控品没有填写编号,则报错
            if (this.comboBox1.SelectedIndex < 2)
            {
                if (this.txtNum.Text.Trim() == "")
                {
                    MessageBox.Show("请填写编号");
                    return;
                }
                if (this.txtConc.Text.Trim() == "")
                {
                    MessageBox.Show("请填写浓度");
                    return;
                }
                //浓度不能是负数
                if (float.Parse(this.txtConc.Text.Trim()) < 0)
                {
                    MessageBox.Show("浓度不能为负值");
                    return;
                }

                //给图形界面赋值
                DgvCtrl.setValueToUI(this.dataGridView0, this.dataGridView1, this.comboBox1.SelectedIndex, this.txtNum.Text.Trim(), double.Parse(this.txtConc.Text.Trim()));
            }
            else
            {
                //如果是空白对照 或未知样品 没填写编号,则报错
                if (this.comboBox1.SelectedIndex >= 2)
                {
                    if (this.txtNum.Text.Trim() == "")
                    {
                        MessageBox.Show("请填写编号");
                        return;
                    }
                }
                //给图形界面赋值
                DgvCtrl.setValueToUI(this.dataGridView0, this.dataGridView1, this.comboBox1.SelectedIndex, this.txtNum.Text.Trim());
            }

            //一旦改动,就不是内置模板了,组合框中的值变为自定义
            this.cmbTpl.SelectedItem = cmbTpl.Items[0];
        }
示例#4
0
文件: Form1.cs 项目: DawnEve/learngit
        private void Form1_Load(object sender, EventArgs e)
        {
            //窗体固定
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;

            //实例化一个dataGridView控制类
            DgvCtrl dc = new DgvCtrl();

            //初始化一个dataGridView
            dc.dataGridView1Init(this.dataGridView1);
            //添加测试数据
            dc.addTestData(this.dataGridView1);
        }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //设定界面底部颜色变化:从rgb和16进制来换算
            //this.label1.BackColor = System.Drawing.Color.FromArgb(69, 209, 208);
            this.label1.BackColor = System.Drawing.ColorTranslator.FromHtml("#008000");
            this.label3.BackColor = System.Drawing.ColorTranslator.FromHtml("#9ACD32");
            this.label5.BackColor = System.Drawing.ColorTranslator.FromHtml("#808080");
            this.label7.BackColor = System.Drawing.ColorTranslator.FromHtml("#87CEFA");

            //添加组合框-内置模板(因为要后续扩展,所以没写死)
            initTplList(0);



            //添加分组单选框-拟合选项
            this.groupBox5.Controls.Add(this.radioButton1);
            this.groupBox5.Controls.Add(this.radioButton2);
            this.groupBox5.Controls.Add(this.radioButton3);
            this.groupBox5.Controls.Add(this.radioButton4);
            this.radioButton1.Checked = true;//默认选中第一项



            //添加组合框-样品类型(因为不需要修改,所以直接写死了)
            string[] well_classes = { "标准品", "质控品", "空白对照", "送检样品" };
            comboBox1.DataSource    = well_classes;
            comboBox1.SelectedIndex = 0;
            //只能选择,不能编辑
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox1.FlatStyle     = FlatStyle.Popup;//样式


            //窗体固定
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;

            //设置数据显示框位置
            this.dataGridView1.Width = 787;
            this.dataGridView0.Width = 787;


            //实例化一个dataGridView类:0控制类
            DgvCtrl.dataGridViewInit(this.dataGridView0, true);


            //实例化一个dataGridView类:1数据显示
            DgvCtrl.dataGridViewInit(this.dataGridView1);
            //添加测试数据
            //DgvCtrl.addTestData(this.dataGridView1);
        }
示例#6
0
        //解析文件
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //openFileDialog1.InitialDirectory = "E:\\";
            openFileDialog1.Filter           = "mub File(*.mub)|*.mub|All files|*.*";
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.FilterIndex      = 2;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string fName = openFileDialog1.FileName;
                //调用类文件读取文件,并获取模板信息、OD信息
                DataReadWrite dfw = new DataReadWrite();
                plate_info   = dfw.readFromFile(fName); //获取基本信息
                Info[,] tpl  = dfw.getTpl();            //模板信息
                double[,] od = dfw.getOd();             //OD信息



                //输出板子基本信息:标题、日期、单位、模型编号
                //this.richTextBox1.Text = "";

                /*foreach (string item in plate_info.Keys)
                 * {
                 *  string info = this.plate_info[item];
                 *  this.richTextBox1.Text += item + " [:] " + info + "\n";
                 * }*/
                this.textName.Text        = plate_info["Name"];
                this.dateTimePicker1.Text = plate_info["LabDate"];
                this.textLot.Text         = plate_info["Lot"];
                this.txtUnit.Text         = plate_info["Unit"];
                //todo 打开文件时曲线类型没处理
                this.richTextBox1.Text = plate_info["Note"];


                //先初始化模板-重置所有方格 + //清空od数据
                DgvCtrl.clearAllCells(this.dataGridView0, this.dataGridView1, true);



                //从中间数据读取到表格中
                DataReadWrite.readIntoUI(tpl, this.dataGridView0, this.dataGridView1); //模板文件
                DataReadWrite.readIntoUI(od, this.dataGridView1);                      //od文件

                //this.richTextBox1.Text += DataReadWrite.textDebug;
            }
        }
示例#7
0
文件: Form1.cs 项目: DawnEve/learngit
        private void Form1_Load(object sender, EventArgs e)
        {
            //窗体固定
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;

            //实例化一个dataGridView控制类
            DgvCtrl dc = new DgvCtrl();
            //初始化一个dataGridView
            dc.dataGridView1Init(this.dataGridView1);
            //添加测试数据
            dc.addTestData(this.dataGridView1);
        }
示例#8
0
 //右键菜单命令-删除
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DgvCtrl.clearSelectCell(this.dataGridView1);
 }
示例#9
0
 //右键菜单命令-剪切
 private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Clipboard.SetDataObject(dataGridView1.GetClipboardContent());
     //this.dataGridView1.CurrentCell = null;
     DgvCtrl.clearSelectCell(this.dataGridView1);
 }
示例#10
0
 //右键菜单命令-粘贴
 private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DgvCtrl.pasteToDataGridView(this.dataGridView1);
 }