PDA

View Full Version : ذخیره مقدار هدر دیتا گرید وقتی مقدار آن سطر True بود



Collector
دوشنبه 15 فروردین 1390, 21:13 عصر
سلام

من یک دیتا گرید دارم میخوام وقتی روی یک سطر کلیک شد . اگر در کالم 2 , 3 ,4 مقدار True بود هدر مربوط به آن کالم در یک تکس باکس ذخیره شود.

من چند تا روش که بلد بودم را امتحان کردم ولی جواب نداد.

لطفا پروژه را اصلاح کنید.

habib_namvar
سه شنبه 16 فروردین 1390, 00:09 صبح
امیدوارم به دردتون بخوره
http://www.upload.iran-forum.ir/uploads/1301953401.zip

Collector
سه شنبه 16 فروردین 1390, 16:34 عصر
ممنون که پاسخ دادید ولی با این کد اگر هر سه چک باکس True باشد کار میکند. من میخواهم اگر بک یا دو چک باکس True بود هم کارکند. با تشکر


if (bool.Parse(dgv1.CurrentRow.Cells["aa"].Value.ToString()) == true && bool.Parse(dgv1.CurrentRow.Cells["ab"].Value.ToString()) && bool.Parse(dgv1.CurrentRow.Cells["ac"].Value.ToString()))
{
txt_test.Text = dgv1.Columns["aa"].HeaderText + " , " + dgv1.Columns["ab"].HeaderText + " , " + dgv1.Columns["ac"].HeaderText;
}

Collector
سه شنبه 16 فروردین 1390, 16:50 عصر
من این رو نوشتم جواب داد


txt_test.Text = "";


if (bool.Parse(dgv1.CurrentRow.Cells["aa"].Value.ToString()) == true)
{
txt_test.Text += dgv1.Columns["aa"].HeaderText + " , ";
}

if(bool.Parse(dgv1.CurrentRow.Cells["ab"].Value.ToString())== true)
{
txt_test.Text += dgv1.Columns["ab"].HeaderText + " , ";
}

if(bool.Parse(dgv1.CurrentRow.Cells["ac"].Value.ToString())== true)
{
txt_test.Text += dgv1.Columns["ac"].HeaderText + " , ";
}