|
-
Feb 4th, 2007, 02:55 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] Location problems. Urgent.
Hi,
Could someone tell me why I'm suddenly getting errors on the following:
I have a form with a panel which has a WMP control in it. I set its location at run time and then after a 10 second timer event it moves to a new location on the screen and options appear. This work fine.
I'm essentially trying to do the same thing on a different form involving a panel and a picture box. I'm not getting the 'Point' property from intellisense. I keep getting errors saying it's not an interface type or something. I've tried with and without the New keyword just in case.
I only get PointConverter or PointF to choose from when i try to set that panel location. Why??
I can't even do things like: Panel1.Location.X = 23
Says expression is a value and therefore cannot be the target of the assignment.
I created a new form, put a panel and picbox and it works. What have I done to make this happen??
-
Feb 4th, 2007, 03:09 PM
#2
Thread Starter
Frenzied Member
Re: [2005] Location problems. Urgent.
I found out what the problem is.
I have an Import Excel statement on the form. The problem only happens when that's there. But the location thing doesn't apply to Excel but every time i put that statement in it says: 'New' Cannot be used on an Interface
Does anyone know how to get around this problem? I see no reason why a panel's location should be causing a problem with Excel
-
Feb 4th, 2007, 04:56 PM
#3
Re: [2005] Location problems. Urgent.
First of all, you absolutely can NOT do this:for the very reaosn that the error message says. The Location property returns a value, i.e. a copy of the value stored in the Panel. If you set the X property of that copy then the original is completely unaffected, so even trying is pointless. The compiler will not allow you to set a property of a property directly when the parent property is a value type for that reason. You would have to set the Panel's Left property, which is what its for. Alternatively you can assign the value of the Location property to a variable, set its X property and then assign the variable back to the Location property.
As for your import issue, I would guess that you are introducing a name clash with your import, i.e. there are two namespaces, types or members with the same name and the IDE is interpreting what you enter as the opposite of what you intend. The norm is to import Office namespaces with an alias:
VB Code:
Imports Excel = Microsoft.Office.Interop.Excel
That means that anywhere you want to refer to the Microsoft.Office.Interop.Excel namespace you type Excel. It means that you don't type as much as you would without the import but there'll be no name clashes as all types within that namespace must be qualified.
-
Feb 4th, 2007, 06:34 PM
#4
Re: [RESOLVED] [2005] Location problems. Urgent.
 Originally Posted by stimbo
I created a new form, put a panel and picbox and it works. What have I done to make this happen??
And this is really working?
-
Feb 4th, 2007, 07:49 PM
#5
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] Location problems. Urgent.
No, the "it works" reference was in regards to the "New Point(x,y)" working on the other form (without Excel reference). That way worked fine with the panel and pic box. Just bad phrasing on my part. I was just trying everything at the end of it because I was so fed up.
I've lost the plot. I don't know why I thought Location.X would work. It obviously wouldn't. The Excel thing was the culprit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|