vb.net - Pass an object from form to another in VB -


i have searched through internet , couldn't find answer problem, but, issue have 2 forms;

frm_bookmaneger

and

frm_addbook

the first 1 main form , has list of books (named listbook), treeview , button invoke second form add new book.

after filling in of textboxes , information of book, press "add". then, second form closed , info of book kept in instance of book class. problem is: how can pass instance first form store in listbook.

for example: if create constructor in form 1 form 2 in form 2:

dim f1 form1 = new form1(me) f1.show() f2.close() 

i can't because form 1 start instantly when start program, , default right doesn't have parameter in oncreatemainform():

protected overrides sub oncreatemainform()         me.mainform = global.windowsapplication5.frm1     end sub 

how can it?

first form:

public class frm_bookmaneger  'list of book dim listbook list(of book) = new list(of book)  private frm_addbook frm_addbook  public sub new(frm_addbook frm_addbook) 'got error     me.frm_addbook = frm_addbook end sub 

second form:

public class frm_addbook  dim public tempbook book = new book()  'add book private sub btn_add_click(sender object, e eventargs) handles btn_add.click     tempbook.bookname1 = textbox_name.text     tempbook.author1 = textbox_author.text     tempbook.price1 = textbox_price.text     tempbook.genre1 = textbox_genre.text     tempbook.establishedday1 = dtp_established.value.date     dim frm_mngr frm_bookmaneger = new frm_bookmaneger(me) end sub  end class 

  dim frm new form1   frm.textbox.text = me.passing value.text    frm.show() 

or can try

public class form1 private loginlabel string  public sub new(byval loginparameter string)      initializecomponent()       me.loginlabel = loginparameter  end sub  end class  dim frm new form1(label.text) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -