Kontaktlardan ma'lumotlarni qo'shish va ularni ListBox-da dinamik tarzda ko'rsatish

My requirement as follows
1) Select the contact from the Contact ( select one or many)
2) Add the Mobile no and Contact name from selected contact in ListBox
3) To delete : Select a contact in the ListBox and delete dynamically and refresh data

My Problems:
a) How to I bind data from contact to ListBox?



 PhoneCtc = new PhoneNumberChooserTask();

PhoneCtc.Completed += new EventHandler(PhoneCtc_Complete);


public void PhoneCtc_Complete(object sender, PhoneNumberResult e)
        {

          string No     = e.PhoneNumber;
          string Name      = e.DisplayName;

// how to add this data dynamically to listbox and display ?

 }

Rahmat

1

1 javoblar

Ro'yxatdagi elementlarning DataTemplate ni quyidagicha belgilang:


  
    
      
        
        
      
    
  
  

Keyin No va Name o'z ichiga olgan Kontakt sinfini yaratishingiz kerak bo'ladi:

public class Contact
    {
        public string No { get; set; }
        public string Name { get; set; }
    }

Now in code when you want to add an element, you just need to initialize an instance class Contact and set variables then write listBox1.Items.Add(Contact);

1
qo'shib qo'ydi
Ishonchim komil emas. PhoneNumberChooser yordamida 10 ta kontaktni tanlasam, kontakt klassi faqat eng so'nggi kontakt ma'lumotlaridan birini saqlaydi. Shunday qilib, bu ListBox faqat bitta kontakt ma'lumotini saqlaydi.
qo'shib qo'ydi muallif MilkBottle, manba
PhoneNumberChooserTask() ni ishga tushirganingizda do'stingiz yo'q, kontakt klassini ishga tushirishingiz va uni ro'yxatga kiritishingiz kerak va u yaxshi ishlaydi va har safar siz ro'yxatga qo'shiladigan kontaktni tanlang. Urunib ko'r :)
qo'shib qo'ydi muallif Ameen, manba