Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys ,

I ve one method created which is the name of ShowInLıstwiev.This brings the records which is saved by any button located in PhoneBook form.

When I save the customer details in PhoneBook Form , I want to display records in MainForm 's listWiev.


I write the code below to the PhoneBook button , but it doesnt show in the listview control of the main form.

C#
MainForm ana = new MainForm();
ana.ShowInListview();


HOW Can else execute this type of some code ?

thanks
Posted
Comments
Sarrrva 27-Aug-12 5:26am    
can you Show your code?

regards
sarva
beratxt 27-Aug-12 6:06am    





public void ShowInListWiev() // my method.when i call it in PhoneBook forms's button , it should get datas to the lisTWiev located in Mainform
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=data.accdb;Persist Security Info=False;");
OleDbCommand veri = new OleDbCommand("SELECT id, ad, soyad,cep,mail,web,operator,adres FROM rehber ORDER BY id", con);
OleDbDataReader oku;
con.Open();//baglantıyı acar
oku = veri.ExecuteReader();//verileri cekme komutunu calıstırır

lstRehber.Items.Clear();//listview in içeriğini temizler
while (oku.Read())//database deki verileri listview e yazdırır
{
ListViewItem rehberItem = new ListViewItem(oku["id"].ToString());
rehberItem.SubItems.Add(oku["ad"].ToString());
rehberItem.SubItems.Add(oku["soyad"].ToString());
rehberItem.SubItems.Add(oku["cep"].ToString());
rehberItem.SubItems.Add(oku["mail"].ToString());
rehberItem.SubItems.Add(oku["web"].ToString());
lstRehber.Items.Add(rehberItem);
}
oku.Close();
con.Close();//baglantıyı kapatır






}
Sarrrva 27-Aug-12 7:01am    
pass your Listview to second form and fill it in there....

its better idea
Sarrrva 27-Aug-12 7:09am    
where is this function located? in mainform or phonebook?

1 solution

Have a look on this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900