سلام
دوستان همچین کدی رو میخوام پیاده کنم به طوری که وقتی کار بر مقدار هر کدام از سلول ها رو نقییر داد بلافاصله در txt من به نمایش بوفته
ضمنا این کد در رویداد های cellckick , cellcounterclick ,cellvaluechanged هم نوشتم ولی همش مقدار صفر رو برمیگردونه و تقییرات هم که لحاظ میکنیم جز عدد صفر چیز دیگه ای نمایش نمیده
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DGV_TEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
textBox1.Text = a.ToString();
}
int a = 1;
int[] array = new int[3];
int[] array2 = new int[1];
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
/* if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[0].Value) == true)
{
array[0] = 1;
}
else array[0] = 0;
if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[1].Value) == true)
{
array[1] = 1;
}
else array[1] = 0;
if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[2].Value) == true)
{
array[2] = 1;
}
else array[2] = 0;
array2[0] = array[0] + array[1] + array[2];
textBox1.Text = array2[0].ToString();*/
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[0].Value) == true)
{
array[0] = 1;
}
else array[0] = 0;
if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[1].Value) == true)
{
array[1] = 1;
}
else array[1] = 0;
if (Convert.ToBoolean(dataGridView1.Rows[0].Cells[2].Value) == true)
{
array[2] = 1;
}
else array[2] = 0;
array2[0] = array[0] + array[1] + array[2];
textBox1.Text = array2[0].ToString();
}
}
}