Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Servermaster Servermaster is offline
Member Aktif
 
Join Date: Nov 2011
Posts: 257
Rep Power: 14
Servermaster mempunyai hidup yang Normal
Default [ASK][C#] Update GridView dari Form Berbeda

Permisi agan mastah sekalian, ane lagi buat aplikasi windows form di C# (VS2010).

Ane punya 2 buah form, misal: FormA dan FormB.



Di FormA terdapat DataGridView.

Ane pengen update/refresh DataGridView tersebut ketika button OK diklik di formB.



Ane dah coba beberapa cara, misal:

- Modifiers di DataGridView di FormA ane ganti menjadi public dengan asumsi dapat dipanggil dari instance FormA di FormB seperti:


Spoiler for FormB:







Code:


//cari record dengan Id = 1
data = from d in MyDB.MyTable
where d.Id.Equals(1) select d;

//instance FormA di Form B
FormA frmA = new FormA();
//DataGridView di FormA yang sudah ane ubah modifiersnya jadi public
frmA.DataGridView.DataSource = data;











- Cara lainnya, ane coba buat public method di FormA:




Spoiler for Cara Lain:






Di FormA:


Code:

public void LoadGridView(){
...
DataGridView.DataSource = data;
..
}

Kalau ane panggil method di atas dari FormA sih OK gan, tapi kalu dari FormB:


Code:

FormA frmA = new FormA();
frmA.LoadGridView();

gak bisa gan











Namun, DataGridViewnya sama sekali tidak terupdate.

Kalau di FormA, ane coba set DataGridView.DataSource = data berhasil gan, tapi gak bisa kalau dari FormB



Mohon bantuanya mastah-mastah sekalian, apakah ada cara terbaik untuk mengupdate GridView dari form yang berbeda



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 12:16 PM.


no new posts