473,608 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 GradientBackgro und_Resize(ByVa l 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(ByVa l sender As Object, ByVal e As System.EventArg s)
Handles MyBase.HandleCr eated
Me.Size = Me.FindForm.Cli entSize
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 AutoresizeToCli entForm(ByVal sender As Object, ByVal e As
EventArgs) Handles m_ClientForm.Re size
Autoresize(send er, 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 1454
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.goo glegroups.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 GradientBackgro und_Resize(ByVa l 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(ByVa l sender As Object, ByVal e As System.EventArg s)
Handles MyBase.HandleCr eated
Me.Size = Me.FindForm.Cli entSize
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 AutoresizeToCli entForm(ByVal sender As Object, ByVal e As
EventArgs) Handles m_ClientForm.Re size
Autoresize(send er, 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
2577
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 good while and I'm getting really frustrated now! My problem is this - my custom controls periodically disappear from my
0
1438
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 created properties to map onto my calendar UI properties like TodayDayStyle, DayStyle, NextMonthStyle, but I think I should add attributes to these properties to make my control more useable when I will insert it in my pages. For example, I've...
0
1323
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 structure. The template items describe how each particular note type of the tree should be rendered (the nodes are data capture elements - bool string and more complicated things). I don't want to use ViewState because of size (there are...
4
2327
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 cookies are not available, so that I get error messages. I just wonder if there are any way such as conditional compile options to overcome the problem? Thanks Charles Zhang
15
6504
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
11
3266
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: <my:RoundedCornerBox id=foo runat=server>
5
4100
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
2
19447
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
7998
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8470
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8329
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4022
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2472
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1580
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1327
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.