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: 15
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

</div>
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


Terkait
Thread Thread Starter Forum Replies Last Post
wts 320 hn 95 form b china UPDATE PIC IndomiKAri Merk lainnya 0 17th October 2013 11:43 AM
Tanya: Biaya bikin STNK dari Form A n Form B BudiPohan Mercedes Benz 0 30th September 2013 03:46 PM
JUAL HQDX Freeza 1st Form, 3rd Form, Final Form | BIB Mulus ORI ! Onepiec3 Action Figures 0 3rd October 2012 08:47 AM
[ask]update command untuk oracle melalui asp.net gridview Darkc0der Programming 0 20th November 2011 12:44 AM
[ask]update command untuk oracle melalui asp.net gridview Braincode Programming 0 11th November 2011 01:16 PM

 


All times are GMT +7. The time now is 08:31 AM.