0 امتیاز

سلام

دوستان همچین کدی رو میخوام پیاده کنم به طوری که وقتی کار بر مقدار هر کدام از سلول ها رو نقییر داد بلافاصله در 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();
 
 
        }
    }
}

 

1 پاسخ

0 امتیاز
سلام ، شما می خواین این کد ها در صورتی فراخوانی بشن که مقدار یک سلول تغییر کنه ، چرا در رویداد CellClick کدها رو نوشتین؟ پروژه رو ضمیمه کنید تا بهتر بشه راهنمایی کرد . از رویداد CellValueChanged می تونید استفاده کنید.
توسط (594 امتیاز) 1 6 33
توسط (6,480 امتیاز) 6 17 129
سوال جدید

2,334 سوال

2,871 پاسخ

3,725 دیدگاه

3,914 کاربر

دسته بندی ها

...