design mode for controls inherited from Windows.Forms.UserControl

C

Crirus

I need to derive the Windows.Forms.Control 2 times so I design a class like
this

Public Class BMControl
Inherits System.Windows.Forms.UserControl

Public Class MapControl
Inherits BMControl


Now, how can I make MapControl editable in design mode just like standard
System.Windows.Forms.UserControl?
Right now, I dont see a UserControl form in design mode, but a large area
non editable....I cant set the size, add controls, and stuffs like it was
System.Windows.Forms.UserControl
 
A

Armin Zingler

Crirus said:
I need to derive the Windows.Forms.Control 2 times so I design a
class like this

Public Class BMControl
Inherits System.Windows.Forms.UserControl

Public Class MapControl
Inherits BMControl


Now, how can I make MapControl editable in design mode just like
standard System.Windows.Forms.UserControl?
Right now, I dont see a UserControl form in design mode, but a large
area non editable....I cant set the size, add controls, and stuffs
like it was System.Windows.Forms.UserControl

I created a new project, added 3 usercontrols, changed the inherits
statement (2nd usercontrol inherits from usercontrol1, 3rd usercontrol
inherits from usercontrol2) and opened usercontrol 3 in the designer: I can
add/modify/remove controls like on Usercontrols directly derived from
Usercontrol. (VB 2003/Framework 1.1) => not reproducable
 
C

Crirus

I inherited directly from Windows.Forms.Control
Anyway, I changed in order to inherit from a control, and still cant set
background image to most derived control
It is not painted on run-time mode, even if I can see it on designer this
time
 
A

Armin Zingler

Crirus said:
I inherited directly from Windows.Forms.Control

The Usercontrol designer does not work for usual Controls. Only the
component designer is available.
Anyway, I changed in order to inherit from a control, and still cant
set background image to most derived control
It is not painted on run-time mode, even if I can see it on designer
this time

Could you please describe the steps again? I think I currently cannot follow
you.
 
C

Crirus

Well, I added a Control to my application
I set the background image on it
I derive another control from it and the background image is not painted in
derived control at run time
 
A

Armin Zingler

Crirus said:
Well, I added a Control to my application

A control or a usercontrol? (derived from Control or from Usercontrol?)
I set the background image on it

how? in code? Using the designer? (there is no designer with a control)
I derive another control from it and the background image is not
painted in derived control at run time


The following code works for me:

Public Class Control1
Inherits System.Windows.Forms.Control

Sub New()
Me.BackgroundImage = Image.FromFile("d:\windows\winnt.bmp")
End Sub
End Class

Public Class Control2
Inherits Control1
End Class


Form:
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load

Dim c As New Control2
c.Size = New Size(100, 100)
Me.Controls.Add(c)
End Sub


It also works doing the following steps:
1. new project
2. add Usercontrol1
3. Set property backgroundimage of usercontrol1
4. add usercontrol2
5. in usercontrol2: change to "inherits Usercontrol1"
6. build
7. put usercontrol2 on the form => backgroundimage already visible
8. run
9. backgroundimage still visible
 
C

Crirus

OK, I have a class derived from UserControl called BMouse
That class modifies mousemove event...
My UserControl is derived from that class, BMouse
I try to set a picture as background of my UserControl
The picture can be seen in design window of the control but is not painted
on runing version...
 
A

Armin Zingler

Crirus said:
OK, I have a class derived from UserControl called BMouse
That class modifies mousemove event...
My UserControl is derived from that class, BMouse
I try to set a picture as background of my UserControl

Of which Usercontrol? You have two. I assume it is the latter one.

Where do you set the picture? Did you open the 2nd Usercontrol in the
designer and set the picture or did you put the 2nd Usercontrol on a Form
and set the picture of the Usercontrol instance? I assume the former.
The picture can be seen in design window of the control but is not
painted on runing version...

I still can not reproduce the problem. How did you add the Usercontrol(s)?
Reason for the question: Is there a "windows forms designer generated code"
region in both controls?




Did you try the steps I described? Which result?
 
C

Crirus

I tryed every posibility
Right now I had added the image to the UserControl in design properties and
also to the instance added to the form
None of this show it in run mode

If I open the UserControl in design I can see the background
But if I open the form with the control added, the control is painted black
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top