[RESOLVED] [2005] Intellisense not listing components
I'm attempting to reference controls on one form from another. For example, depending on certain conditions I might want to show hidden controls on form A when opening from form B. I have done this sucessfully several times in my application.
But now, when I try accessing the control, the error: 'dtpAddyEnd' is not a member of 'System.Windows.Forms.Form' displays.
The controls are accessible in form A's .vb code without issue.
The code snippet from form B is:
Code:
Dim frm as Form
frm = New frmClientAddyAdd
frm.dtpAddyEnd.visible = True
frm.ShowDialog()
which is identical to code in forms that work.
I've looked in form A's Designer code to see if anything looked out of place, but was unable to see a problem.
I've tried cleaning the code and rebuilding. I closed out of VS and reopened, but all to no avail.
Any suggestions?
Vic
Re: [2005] Intellisense not listing components
that's because frm is dimmed as a form.... not frmClientAddyAdd .... if you change it from
to
Code:
Dim frm As frmClientAddyAdd
you might find you get the intellisense you expect.
To further it.... the intellisense is based on the TYPE of the variable.... not what it actually gets set to.... which is how you were expecting it to work.
-tg
Re: [2005] Intellisense not listing components
I changed the Dim statement to:
Dim frm As New frmClient AddyAdd
and the code was recognized.
Don't understand the distinction. But at least I got it to work.
Vic
Re: [2005] Intellisense not listing components
Quote:
Originally Posted by veepm
Don't understand the distinction. But at least I got it to work.
Vic
The distinction is quite simple. The intellisense is based of of what you declare the variable to be. A Form variable does not have a property called dtpAddyEnd, so it doesn't show up. A frmClientAddyAdd does have a variable called dtpAddyEnd, so it shows up.
Re: [RESOLVED] [2005] Intellisense not listing components
Form is the base, generic data type.... it's like saying something is a "number" ... doesn't mean much.... number could mean anything including 2.1. But if some thing was declared as an Integer.... well, then 2.1 o longer becomes a valid value. Samething happens when something is declared as a "Form" ... ti could be any kind of form.. a login form, a dialog form, your main form... some other form.... so intellisense has no way of knowing what controls are available on the "form" because it doesn't know WHAT form you're talking about. by diming it as a specific form type, well, now you've narrowed it down to a specific form type. And from THAT the IDE can figure out what's available.
-tg