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

DesignMode broken - suggested path?

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. There was a suggestion...

Protected Shadows ReadOnly Property DesignMode() As Boolean
Get
If (MyBase.DesignMode) Then
Return True
Else
Dim parent As Control = Me.Parent
While Not (parent) Is Nothing
Dim site As ISite = parent.Site
If Not (site) Is Nothing AndAlso
site.DesignMode Then
Return True
End If
parent = parent.Parent
End While
Return False
End If
End Get
End Property

....but this suggestion does not work effectively. Does anyone know of
another way and/or a supplement to this recursive function that I am
not seeing? I've heard that you can use GetCurrentProcess, but that
didn't seem to work for me.

Thanks,

Kyjan

Jun 29 '06 #1
4 1457
Kyjan,

I don't know if others understand this text but I don't.

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. There was a suggestion...

A user control can be placed on every form, therefore I have the idea that
you mean something else?

Cor
Jun 29 '06 #2
My apologies, I should have elaborated a little more.

I have created a user control that has some code that needs to run in
the Load event. When I compile the user control and then place the
user control on another form, because of the fact that the designer
actually instantiates the class, it runs the code in the Load event.
I'm trying to prevent that by testing the DesignMode property.
However, it's not working correctly because even though the UC might
not be in design mode, the form that the UC is on is in DesignMode.

Kyjan

Cor Ligthert [MVP] wrote:
Kyjan,

I don't know if others understand this text but I don't.

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. There was a suggestion...

A user control can be placed on every form, therefore I have the idea that
you mean something else?

Cor


Jun 29 '06 #3
Does anyone have any suggestions?

Kyjan

Jun 30 '06 #4
I would put your code into a public subroutine of the control and call it
from the load event of the form instead of the load event of the control -
assuming that will accomplish what you want. As you've found, you can't
rely on control events to happen when you think they should. In VS03 I've
had a lot of problems with user controls firing events at odd times and
repeatedly. It's a little more work, but it works for me.

hth;

DCraig.
"Kyjan" <Ho***********@gmail.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
Does anyone have any suggestions?

Kyjan

Jun 30 '06 #5

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...
1
by: Paul W | last post by:
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
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...
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...
3
by: Giampaolo Rodola' | last post by:
Hi there, I would like to know if such function would be correct for verifying if a link is broken and/or circular. def isvalidlink(path): assert os.path.islink(path) try: os.stat(path)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.