473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 21 '05 #1
5 1200
> 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 21 '05 #2
> 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 21 '05 #3
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 21 '05 #4
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 21 '05 #5
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 21 '05 #6

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

Similar topics

3
by: Z D | last post by:
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...
3
by: 42 | last post by:
Hi, I've run into a block, that I'm almost sure is really simple...but I can't seem to clue in right now. I'd like to create a user control that takes input like this: <mycontrol:panel...
6
by: Andrea Williams | last post by:
When I step through my code, the ASPX Page_Load happens before the Page_Load in the User Control. This means that the property values are not set to their defaults yet in the User Control and all...
2
by: Stan Sainte-Rose | last post by:
Hi guys, I have a page with several textboxes.. In the same page, I set a user control with a button. I would like to know how to catch the different values from the textboxes when I click on the...
4
by: Chad | last post by:
I have a link (.ascx) and that generates an Add form on that page. The autopostback dropdown is within a "If Not IsPostBack Then" statement. The form that is created is all via static html in the...
0
by: Doug Handler | last post by:
Hi, I have a form (Form1) that contains a tab control which one tab has a customer user control (UserControl1). When the user double-clicks on the grid hosted there a new user control is...
5
by: Doug Handler | last post by:
Hi, I have a form (Form1) that contains a tab control which one tab has a customer user control (UserControl1). When the user double-clicks on the grid hosted there a new user control is...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.