472,975 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,975 software developers and data experts.

User Control Question

Z D
Hello,

I've created a winform user control that, at some point in the default
constructor, looks for a specifc file.

When I try to load the user control to my winform's form during design time
it gives an error saying that the file doesn't exist.

Obviously the file doesnt exist yet because its only created at runtime!!

So, why is the design-time environment (VS.NET 2003) trying to compile my
app when I load the user control onto the winform?

Anyways - if I comment out references to this file in the control then I can
add it with no problems to the winform.

My question is: How do I disable this functionality so that Visual Studio
doesnt try to "be too smart" during design time?

Thanks!
-ZD
Nov 16 '05 #1
3 2343
> My question is: How do I disable this functionality so that Visual Studio
doesnt try to "be too smart" during design time?

I'm just getting into this c# stuff so I might be a bit off the mark here,
but instead of having disabling VS designtime functionality, why not have
your code itentify runtime vs design time and not do your file check at
design time? Would that work? I came from java/JB and that's how javabeans
are usually done for these problems. Good luck.
Nov 16 '05 #2
ZD,

The IDE in a way needs to run the constructor to do all the control specific
renderings to make the control look like as close to possible as it would in
realtime. So if in your constructor you drew a blue line across the control,
the control will draw the blue line on itself in the designer only by
calling the default constructor. Basically you want to stay away from the
default constructor, InitializeComponent and the "load" event for this
purpose.

You can implement a non-default constructor (one that will take parameters)
to get around this issue.

Also there is a "DesignMode" property on the control - probably won't work
in your case because DesignMode is always false in the constructor.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
Please reply to the newsgroups instead of email so everyone can benefit from
your reply.
"Z D" <no****@nospam.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Hello,

I've created a winform user control that, at some point in the default
constructor, looks for a specifc file.

When I try to load the user control to my winform's form during design time it gives an error saying that the file doesn't exist.

Obviously the file doesnt exist yet because its only created at runtime!!

So, why is the design-time environment (VS.NET 2003) trying to compile my
app when I load the user control onto the winform?

Anyways - if I comment out references to this file in the control then I can add it with no problems to the winform.

My question is: How do I disable this functionality so that Visual Studio
doesnt try to "be too smart" during design time?

Thanks!
-ZD

Nov 16 '05 #3
I realize this solution is probably considered crude, but when nothing else
works, including the use of a separate thread, it can be useful.

At the end of the Constructor, start a timer, with the increment setting at
200 (you can probably shorten that if this works for you) . In the tick
event of the timer, Stop the timer on the first line of code. Then test
whether the code is processing in design time with me.designtime. If not,
the code is processing in runtime, you can get the file and process it in the
timer event handler.

Note: You can add a messagebox while you're testing this to show that the
code after "If me.designmode = false then" is not running in design time. As
another poster on this thread pointed out me.designmode is always false in
the Constructor. In the timer, however, it is set according to the current
mode.

www.charlesfarriersoftware.com
"Z D" wrote:
Hello,

I've created a winform user control that, at some point in the default
constructor, looks for a specifc file.

When I try to load the user control to my winform's form during design time
it gives an error saying that the file doesn't exist.

Obviously the file doesnt exist yet because its only created at runtime!!

So, why is the design-time environment (VS.NET 2003) trying to compile my
app when I load the user control onto the winform?

Anyways - if I comment out references to this file in the control then I can
add it with no problems to the winform.

My question is: How do I disable this functionality so that Visual Studio
doesnt try to "be too smart" during design time?

Thanks!
-ZD

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Lloyd Sheen | last post by:
Is there any one who has actually done this. I have now scanned more web articles about this with the realization that not one of them (including MSDN docs) outlines how to do this. This is...
6
by: Jim Heavey | last post by:
Hello, I have a user control which I place at the top of each page. I want to have code in this user control which sets the value of a couple of module variables and I was wondering if I create a...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
0
by: campwes | last post by:
Hey there. I have a user control on an aspx page that displays data based on a query (handled by another user control also on the page). I've noticed that the first time I navigate to the page...
0
by: Brian Cesafsky | last post by:
I am using framework 1.1 I have a user control and a web page. I want to set up properties on the user control, so I can access the text boxes on the user control when I am in the code behind...
0
by: Brian Cesafsky | last post by:
I am using framework 1.1 I have a user control and a web page. I want to set up properties on the user control, so I can access the text boxes on the user control when I am in the code behind...
1
by: weboweb | last post by:
Hello aspnet experts! I have a design question for the more experienced developers (more than me at least :-)). 1) I have a page in the application I'm building that displays a web user...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.