473,401 Members | 2,146 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,401 software developers and data experts.

Detecting DesignMode

I'm having trouble detecting whether my Control is in DesignMode. I'm
deriving a class from TreeView;

Public Class ExplorerView
Inherits TreeView

...

End Class

But when I want to see if it's in DesignMode, neither Me.DesignMode or
MyBase.DesignMode work, they always return False. The documentation states
that the class must implement ISite for DesignMode to return any other value
than False, so, I try to implement ISite, and I get errors stating I'm
trying to override a nonoverridable method. That says to me, TreeView is
already implenting ISite, but if that's true, why can't I get a meaningful
value from the DesignMode property. Any ideas? Thanks in advance.

Paul W
Nov 20 '05 #1
1 2183

"Paul W" <no****@vbtips.net> wrote in message
news:u%******************@TK2MSFTNGP11.phx.gbl...
I'm having trouble detecting whether my Control is in DesignMode. I'm
deriving a class from TreeView;

Public Class ExplorerView
Inherits TreeView

...

End Class

But when I want to see if it's in DesignMode, neither Me.DesignMode or
MyBase.DesignMode work, they always return False. The documentation states that the class must implement ISite for DesignMode to return any other value than False, so, I try to implement ISite, and I get errors stating I'm
trying to override a nonoverridable method. That says to me, TreeView is
already implenting ISite, but if that's true, why can't I get a meaningful
value from the DesignMode property. Any ideas? Thanks in advance.

Paul W

OK, it looks as if I've solved this problem. The way the documentation
reads, leads you to believe that the way ISite is implemented is going to be
the problem, they fail to mention the more obvious. The code I needed to
run only if *not* in DesignMode was in the Constructor, which is typical in
this situation. However, this is to soon to determine if you're in
DesignMode, the control hasn't been sited yet, hence the False value.

The solution is to implement the ISupportInitialize interface. This
interface has two methods, BeginInit & EndInit. EndInit is called when the
component is finished initializing and is therefore the proper place to put
code that relies on the DesignMode property.

Paul W
Nov 20 '05 #2

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

Similar topics

1
by: Thomas | last post by:
Hy dudes, I have a strange problem. I dynamically create an IFrame with JavaScript and then fill in some content. Afterwards I want to switch to designMode. There the trouble starts. In Mozilla...
2
by: Lecture Snoddddgrass | last post by:
Hi, When I create a UserControl-derived object, I often expose various public properties. One of the things that I hate about the WinForms designer is that if I decide to embed one of these...
1
by: Tiago Barbutti | last post by:
I have a UserControl that execute methods in Load event, but it hapens in designMode and generate an error and the control disappear from the form. I read that i can use the DesignMode to kwnow...
2
by: Malleier Alfred | last post by:
Hi, what does the Me.DesignMode-Property turn back. I tried to set a MsgBox(Me.DesignMode) in my form's and control's Sub New(), but it allways turns back 'false', even if the form or control is...
29
by: Charles Law | last post by:
Further to my issue about user controls, I have a problem with DesignMode. Here is the project hierarchy: MainApp |_ Project1 |_ SubProject (UserControl) SubProject has a default constructor...
7
by: MuZZy | last post by:
Hi, I have a user control which connects to a database in it's OnLoad event handler. When the user control is on a form and i open this form in VS designer, i get an exception regarding database...
2
by: Simon Rigby | last post by:
Hi folks, I'm trying to switch an iFrame in and out of design mode by way of a script. As you can see from the method it is intended to be cross browser compatible (or FF and IE at least). The...
4
by: Kyjan | last post by:
Greetings! In doing some research, I've learned that some other people have had problems with Me.DesignMode not working correctly when it's used in a user control that is placed on another form....
2
by: graeme g | last post by:
ii i've been developing some usercontrols... and sudden the property designmode no longer works.. if i test it value at designtime it always comes back false... i've made a work around if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.