473,320 Members | 1,910 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,320 software developers and data experts.

Custom control creation problem, please....

Hi. I am creating a user control in vs2005 which is supposed to provide
a fancy gradient background - in theory, you just drop it on a form,
you set the start/end colors, the gradient type, and you're done....
but that's in theory. It should repaint itself, it should take the size
of the client form (the form you're dropping it on), and it should
resize & repaint itself when the client form is resized.

I have added the following proc for forcing a repaint when the user
control is resized:

___________________________________
Private Sub GradientBackground_Resize(ByVal sender As Object, ByVal e
As EventArgs) Handles MyBase.Resize
Me.Invalidate()
End Sub
___________________________________

I have also added this for making the user control take the full size
of the client form:

___________________________________
Sub Autoresize(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.HandleCreated
Me.Size = Me.FindForm.ClientSize
Me.Location = New Point(0, 0)
End Sub
___________________________________

Nice and dandy. It works until the user resizes the client.

I DON'T KNOW how to make the user control resize when the client form
gets resized. Of course, I could write code in the client form, but
that defeats the purpose of the whole exercise, isn't it ? The user
control should be self contained.

How would one do that ? One idea I had was to somehow obtain a handle
to the container (the client form) like so:

___________________________________
Dim WithEvents m_ClientForm As System.Windows.Forms.Form

Public Sub New()
m_ClientForm = Me.Parent
End Sub

and then define a proc like this:

Sub AutoresizeToClientForm(ByVal sender As Object, ByVal e As
EventArgs) Handles m_ClientForm.Resize
Autoresize(sender, e)
End Sub
___________________________________

but it doesn't work. I also tried with Me.Container. Both are always
NOTHING...
How could I solve this problem, please ?

Thank you very much.
Alex

Apr 5 '06 #1
2 1438
You can update the control style to add the ResizeRedraw flag.
http://msdn2.microsoft.com/en-us/lib....setstyle.aspx

To have the custom UserControl take up the entire client area of its
container (parent) set the UserControl's Dock property to DockStyle.Fill.

--
Tim Wilson
..NET Compact Framework MVP

"Radu" <cu*************@yahoo.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
Hi. I am creating a user control in vs2005 which is supposed to provide
a fancy gradient background - in theory, you just drop it on a form,
you set the start/end colors, the gradient type, and you're done....
but that's in theory. It should repaint itself, it should take the size
of the client form (the form you're dropping it on), and it should
resize & repaint itself when the client form is resized.

I have added the following proc for forcing a repaint when the user
control is resized:

___________________________________
Private Sub GradientBackground_Resize(ByVal sender As Object, ByVal e
As EventArgs) Handles MyBase.Resize
Me.Invalidate()
End Sub
___________________________________

I have also added this for making the user control take the full size
of the client form:

___________________________________
Sub Autoresize(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.HandleCreated
Me.Size = Me.FindForm.ClientSize
Me.Location = New Point(0, 0)
End Sub
___________________________________

Nice and dandy. It works until the user resizes the client.

I DON'T KNOW how to make the user control resize when the client form
gets resized. Of course, I could write code in the client form, but
that defeats the purpose of the whole exercise, isn't it ? The user
control should be self contained.

How would one do that ? One idea I had was to somehow obtain a handle
to the container (the client form) like so:

___________________________________
Dim WithEvents m_ClientForm As System.Windows.Forms.Form

Public Sub New()
m_ClientForm = Me.Parent
End Sub

and then define a proc like this:

Sub AutoresizeToClientForm(ByVal sender As Object, ByVal e As
EventArgs) Handles m_ClientForm.Resize
Autoresize(sender, e)
End Sub
___________________________________

but it doesn't work. I also tried with Me.Container. Both are always
NOTHING...
How could I solve this problem, please ?

Thank you very much.
Alex

Apr 5 '06 #2
Thanks a lot ! It works :-))

Apr 5 '06 #3

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

Similar topics

2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
0
by: Julien | last post by:
Hi ! I'm creating a custom control, in which I would render an image with client-side script code to display/hide a calendar control which also belong to my custom control. In this control I've...
0
by: Iain | last post by:
Can I apologise for the lengthy nature of this post. The scenario is complicated (though I hope the solution is not!) basically, I've got a custom template control which binds itself to a tree...
4
by: Charles Zhang | last post by:
I created a custom server control whose rendering logic relies on session variables and cookies. It works just fine at run time. The problem is at the design time, because session variables and...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.