将所选单元格的值更改为0(零) [英] Change value of selected cells to 0 (zero)

查看:127
本文介绍了将所选单元格的值更改为0(零)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

想问你,如何在datagridview中更改所选单元格的值?

Would like to ask you, how can i change the value of selected cell in datagridview?

I在我的表单上有一个按钮"Null Cell"我想在datagridview上按下一个单元格(可能不止一个)并按下"Null Cell"。将值更改为0.。

I have a button on my form "Null Cell" and i would like to press on a cell (maybe more than one) on datagridview and by pressing "Null Cell" change the value to 0.

非常感谢,

此致,

Adil Aliyev

Adil Aliyev

推荐答案

对于当前单元格

For the current cell

public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
        Shown += Form1_Shown;
    }

    private void Form1_Shown(object sender, EventArgs e)
    {
        dataGridView1.Rows.Add(1, "Karen", "Payne");
        dataGridView1.Rows.Add(2, "Mary", "Smtim");
        dataGridView1.Rows.Add(3, "Bill", "Jones");
    }
    private void button1_Click(object sender, EventArgs e)
    {
        if (dataGridView1.CurrentRow != null && dataGridView1.CurrentRow.IsNewRow) return;
        dataGridView1.CurrentCell.Value = 0;
    }
}


这篇关于将所选单元格的值更改为0(零)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆