//method that reacts when an element is selected from the ListBox private void åbentHus_boligListe_lbox_SelectedIndexChanged(object sender, EventArgs e) { //saving the selected item in a variable var text = åbentHus_boligListe_lbox.SelectedItem; //initialization of a string[] that will contain a serie of Bolig ID string[] boligid; if (text != null) { try { //split the text to find the BoligID boligid = text.ToString().Split(' '); //calling method HentOpdaterBolig with parameter string BoligID (the one we've just found) //this method opens the window to retrieve a BoligBLL from the db //with the BoligID passed in the parameter (aka. the selected item in the form) MenuBarKnapper.HentOpdaterBolig(boligid[1]); } catch (NullReferenceException ex) { Console.WriteLine(ex.Message); } } }
private void readToolStripMenuItem3_Click(object sender, EventArgs e) { MenuBarKnapper.HentOpdaterBolig(); }
private void bolig_readToolStripMenuItem2_Click(object sender, EventArgs e) //Hent og opdater bolig { MenuBarKnapper.HentOpdaterBolig(); }