winforms - Refreshing a specific instance of a form from another form in vb.net -
ok, google-fu may weak, i'm having issue seems should pretty easy past, try not working. , have special case makes many examples not relevant application.
here's i'm trying do: have listbox on form1 populated database. have button on form1 opens form2 user can enter date , time. date , time, plus additional info, written database, , form2 closes.
what i'm wanting have write or close event on form2 cause refresh of info in listbox in form1.
the 1 major consideration user might have 20+ instances of form1 opened @ 1 time. want refresh form1 spawned it.
i have many buttons on form1 correctly refresh listbox following code:
private sub refreshtimeline() timelinelistbox.items.clear() try myconnection.connectionstring = connstring myconnection.open() dim str string str = "select tleventtime,tleventnotes timeline eventid = '" & eventid & "'" dim cmd5 oledbcommand = new oledbcommand(str, myconnection) dr = cmd5.executereader() while dr.read() dim eventtime = dr("tleventtime").tostring dim eventnotes = dr("tleventnotes") dim tl = "[" & eventtime & "] - " & eventnotes & "" timelinelistbox.items.add(tl) end while myconnection.close() catch exerror systemexception msgbox("an error occurred. " & exerror.message) myconnection.close() end try end sub
in short, proc run when form2 closes, user see changes in listbox. on right form1 (not hurt refresh form1's, number of users have, , number of form1's have open, db hit concern). working i've tried making proc public, , calling form2. , though vs 2010 thought good, , seemed linking correctly, doesn't trigger proc.
what you, great , mighty stackoverflow?
Comments
Post a Comment