现在的位置: 首页 > 综合 > 正文

批量修改DataGridView中的数值数据

2013年08月25日 ⁄ 综合 ⁄ 共 1746字 ⁄ 字号 评论关闭

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

namespace Wage
{
    public partial class frm_PiLiang_Shuju_XiuGai : Form
    {
        DataGridView dgv = new DataGridView();//传入的参数
        double shuju;
        public frm_PiLiang_Shuju_XiuGai()
        {
            InitializeComponent();
        }

        private void button_QuanXuan_Click(object
sender, EventArgs e)

        {
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                dgv.Rows[i].Cells["isSelect"].Value = true;
            }
        }

        private void button_XiuGai_Click(object sender, EventArgs e)
        {
            dgv = this.dataGridView1;
            //检查数据是否有效
            int xiugai_Column = this.comboBox_XuanZe_XiangMu.SelectedIndex;
            if (this.comboBox_XiuGai_FangShi.SelectedIndex == -1)
            {
                MessageBox.Show("请选择修改方式。", "提示 修改方式", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;

            }
            if (this.comboBox_XuanZe_XiangMu.SelectedIndex == -1)
            {
                MessageBox.Show("请选择项目。", "提示 选择项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (String.IsNullOrEmpty(this.textBox_GongZi_ShuJu.Text.Trim()))
            {
                MessageBox.Show("请输入数据。", "提示 工资数据", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                double gongzi_Shuju = Convert.ToDouble(this.textBox_GongZi_ShuJu.Text.Trim());
                shuju = gongzi_Shuju;
            }
            catch (Exception ex)
            {
                MessageBox.Show("请在“工资数据”框输入有效的数字。", "提示 工资数据", MessageBoxButtons.OK, MessageBoxIcon.Error);
          

抱歉!评论已关闭.