473,394 Members | 1,266 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,394 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 2178

"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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.