با سلام
فرض بر اين که ميخواهيم با لود فرم ،تمام سطر هاي 2تا فيلد يک table را در dataGridVieW نشون بديم. چه کدي با يد موقع لود بنويسم
با تشکر
Printable View
با سلام
فرض بر اين که ميخواهيم با لود فرم ،تمام سطر هاي 2تا فيلد يک table را در dataGridVieW نشون بديم. چه کدي با يد موقع لود بنويسم
با تشکر
اين كار به دو بخش تقسيم ميشه
اول واكنش اطلاعات از بانك اطلاعاتي
مشخص كنيد بانكتون چيه sqlserver,sqlite,access,xml,excel,....
مشخص كنيد از چه روشي ميخواين استفاده كنين ef,linq,ado,....
دوم ريختن اطلاعات داخل dgv
حالا تو كدوم بخش مشكل دارين؟
دو تا ستون مورد نظرتون رو داخل دیتا گرید ویو ایجاد کنید
سپس dgv.DataSource=dt
یا روش بهتر اینه با یک دیتور سلکت دو فیلد مورد نظر رو با تمام سطرها بدست بارید و داخل گرید قرار بدبد
select field1,field2 from yourtb و نتیجه کوئری رو داخل یک جدول قرار بدید و سپس
dgv.DataSource=dt
بانکم sql
به روش ado
DataTable daftarche = new DataTable();
daftarche.Columns.Add("شرح سوال ");
daftarche.Columns.Add("گزينه 1 ");
daftarche.Columns.Add("گزينه 2 ");
daftarche.Columns.Add("گزينه 3 ");
daftarche.Columns.Add("گزينه 4 ");
for (int i = 0; i < 4; i++)
{
DataRow dr = daftarche.NewRow();
dr["شرح سوال "] = "sharh";
dr["گزينه 1 "]= "g1";
dr["گزينه 2 "] = "g2";
dr["گزينه 3 "] = "g3";
dr["گزينه 4 "] = "g4";
daftarche.Rows.Add(dr);
}
dw.DataSource = daftarche;
تا اينجا هم از روي يه pdf اموزش پيش رفتم.ولي ميخوام بجاي g1 و... اطلاعات ديتابيسو بياره