Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Control Selection & Resizing at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
for1248 - 08 Jan 2008 13:04 GMT
I have a common mousemove/down/up handler for any control placed on the panel
at runtime .It's Working fine .

I need for moving and resizing controls (labels/textboxes/checkboxes/etc) and
shape controls (LineShape ,RectangleShape, OvalShape which are from
powerpacks.dll ) which i  place on the Panel which are generated at runtime .

Is there any Class for creating Control Selection and Resizing Handles  for
my controls which are present on the panel at runtime ??????

I want to show the selection if user presses the control and able to resize
those controls with resizing handles for Any Typeof control . ?????  


' If i release the mouse button after resizing it has to update the size or
location of that control  same like in vs2005 design time environment but
here at runtime .

plzzz ,



Thanks & Regards
Mike Powell - 08 Jan 2008 13:29 GMT
Hi,
there is no built in way to do this with .net however since you capture the
mouse up down and move events you shouldn't have any problem coding this
kind of thing.  I've made a few ResizerRects as i call em, just make a class
which has a rectangle and however many grab handles you want, then just
handle resizing that rectangle as desired (grabhandle, Size property...)
once you have this simple control set up to behave how you want it, you just
need to create one for each object dragged onto the form and use it as a
sort of container, this makes sure that no matter what kind of object is
dragged onto the form, moving and resizing is always handled the same way
I'll look through my backups to see if i can find you an example (old
machines in bits for now).

Regards,

Michael Powell
Ramuseco ltd .Net Consulting

P.S
you may find the ControlPaint class useful, check it out.

>I have a common mousemove/down/up handler for any control placed on the
>panel
[quoted text clipped - 22 lines]
>
> Thanks & Regards
dotnet2005 - 10 Jan 2008 12:17 GMT
Thanks For Replying ,

That ControlPaint is very useful ,But i am getting only 3 squares at
different places not on control edges .Only at a particular place
those are coming not for individual controls at that location .

Thanks
For1248
dotnet2005 - 10 Jan 2008 12:45 GMT
Hii ,

I will come with a nice reply ,Sorry for the previous one .I am doing
practicles on that thing now i understood something ,

I will be back .Please reply me

Thanks
For1248
dotnet2005 - 11 Jan 2008 04:45 GMT
HI Powell ,

Now i am able to  draw rectangles on any particular control if i
click , but the thing is it is not able to recognize the
LineShape,RectangleShape,OvalShape which are from
VisualBasic.PowerPacks.Dll  if click on those shapes ,but recognizing
controls of type Control
if i click a button on toolstrip it creates Rectangle
While creating like this on panel ::
Dim shc As ShapeContainer = New ShapeContainer()
           shc.Location = New System.Drawing.Point(0, 0)
           shc.Margin = New System.Windows.Forms.Padding(0)
           shc.Name = "ShapeContainer1"
           Rect = New RectangleShape(shc)
           Rect.Location = New System.Drawing.Point(ihorizontal,
ivertical)
           Rect.Size = New Size(70, 40)
           Rect.Name = "RectangleShape1"
           Rect.Enabled = False
           CurrentPanel= SampleForm.Panel1.Controls("Page" &
CurrentPanelNo)
           cs.WireControl(Rect) --- Used from CodePRoject PICKBOX
project --not working on shapes
           CurrentPanel.Controls.Add(shc) --------------- Adding to
Current Panle
           g = CurrentPanel.CreateGraphics
           'AddHandler ctr.MouseDown, AddressOf Ctr_MouseDown
           AddHandler Rect.MouseClick, AddressOf Ctr_MouseClick
           'AddHandler ctr.MouseLeave, AddressOf Ctr_MouseLeave
           'AddHandler ctr.MouseUp, AddressOf Ctr_MouseUp

while Ctr_MouseClick  i am writing this thing to get handle around
that control
If TypeOf sender Is TextBox Then
           ctr = DirectCast(sender, TextBox)
  ControlPaint.DrawSelectionFrame(g, True, Rectangle.Inflate(Box,
boxsize, boxsize), Box, Color.DarkBlue)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left - 6,
ctr.Top - 6, boxsize, boxsize), True, True)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width / 2 - 6, ctr.Top - 6, boxsize, boxsize), True, True)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width, ctr.Top - 6, boxsize, boxsize), True, True)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left - 6,
ctr.Top + ctr.Height, boxsize, boxsize), True, True)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width / 2 - 6, ctr.Top + ctr.Height, boxsize, boxsize), True,
True)
       ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width, ctr.Top + ctr.Height, boxsize, boxsize), True, True)
 ElseIf TypeOf sender Is LineSelection Then          ----- Not
Recognizing the click
           Line = CType(sender, LineShape)
......

But not Working .........

Thanks & Regards ,
For1248
anoj - 09 Jan 2008 07:25 GMT
Hi,

Though there is no built in functionality available but same can be
achieved using
SharpRectTracker control.
http://www.codeproject.com/KB/miscctrl/CSharpRectTracker.aspx

Hope this helps.

/Anoj Kumar
[htttp://techtips4you.blogspot.com]

> I have a common mousemove/down/up handler for any control placed on the panel
> at runtime .It's Working fine .
[quoted text clipped - 16 lines]
>
> Thanks & Regards
dotnet2005 - 10 Jan 2008 12:13 GMT
Hii ,

Thanks For replying ,

This is the thing which i want for runtime . I used that thing but it
is of type controls inherits from COntrol .

Thanks

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.