feurich Posted November 24, 2003 Posted November 24, 2003 I'm trying to add controls to a controls collection of a form by doing this: Dim oADMvtrlColl as frmAdmin.Controlscollection '*** make an instance of the ctrlcollection of the admin form. in an input form I try to add a controls dynamically by doing this: oADMctrlColl.add(cbobox) '** Combo box has been created dynamically But the error : object reference not set to an instance of an object What am i doing wrong Cire Quote Trust the Universe
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 would me.controls.add(cbobox) not work? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
feurich Posted November 24, 2003 Author Posted November 24, 2003 No because the combobox is on a different form. I have a combobox input form frmCBInput and from that form I have to add a combo box with values to the frmAdmin form in a specific location. Cire Quote Trust the Universe
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 given a valid instance of the frmAdmin held in a variable f you could do f.Controls.Add(cbobox) then. you cannot refer to frmAdmin direct as it is a class and not a running instance of the form. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
feurich Posted November 24, 2003 Author Posted November 24, 2003 When I add Byval f as frmMain to the parameter of the btnOK_click event of the frmLBInput form the last part of the line "Handles btnOK.click" gets an error. Method 'btnOk_Click' cannot handle Event 'Click' because they do not have the same signature. Where does the "Byval f as frmmain" need to go?? Quote Trust the Universe
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 You could provide an overloaded constructor: within frmLBInput add private f as frmMain sub New (frm as frmMain) f=frm end sub and when you create your instance of frmLBInput (from frmMain?) dim frm2 as new frmLBInput(me) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
feurich Posted November 24, 2003 Author Posted November 24, 2003 2 input forms Can you do this also with 2 input forms that reference the same frmAdmin form ? Quote Trust the Universe
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 Should be able to do it - just override the sub new for each of them Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
feurich Posted November 25, 2003 Author Posted November 25, 2003 You where right OK it was a typeo from my side.. :rolleyes: Quote Trust the Universe
Nightyhawk Posted November 25, 2003 Posted November 25, 2003 Re: You where right OK it was a typeo from my side.. :rolleyes: Don't ya love typos. Spell checkers are your best friend, or else Code Smart which Microsoft is not thinking when they didn't create such a tool themselves :P Quote Take care, Lori :D --DreamWEBCatcher.com
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.