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

how can i make my own control fro text and can be s

hi everybody
i need help to make special control that will contain text
and can be resizable and move by mouse

like the how we do in visual studio when we are programing
:$



how can i do one like it,
or if there is exist one

thanx in advanced
Oct 1 '08 #1
10 1321
OuTCasT
374 256MB
This is how you move the control around on the form. just changed the btnMove to the name of the control that you want to be able to move.

Expand|Select|Wrap|Line Numbers
  1. Inherits System.Windows.Forms.Form
  2.     Public Dragging As Boolean
  3.     Public mousex, mousey As Integer
  4.  
  5. Private Sub btnMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseDown
  6.         If e.Button = MouseButtons.Left Then
  7.             Dragging = True
  8.             mousex = -e.X
  9.             mousey = -e.Y
  10.             Dim clipleft As Integer = Me.PointToClient(MousePosition).X - btnMove.Location.X
  11.             Dim cliptop As Integer = Me.PointToClient(MousePosition).Y - btnMove.Location.Y
  12.             Dim clipwidth As Integer = Me.ClientSize.Width - (btnMove.Width - clipleft)
  13.             Dim clipheight As Integer = Me.ClientSize.Height - (btnMove.Height - cliptop)
  14.             Cursor.Clip = Me.RectangleToScreen(New Rectangle(clipleft, cliptop, clipwidth, clipheight))
  15.             btnMove.Invalidate()
  16.         End If
  17.     End Sub
  18.  
  19.     Private Sub btnMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseMove
  20.         If Dragging Then
  21.             'move control to new position
  22.             Dim MPosition As New Point()
  23.             MPosition = Me.PointToClient(MousePosition)
  24.             MPosition.Offset(mousex, mousey)
  25.             'ensure control cannot leave container
  26.             btnMove.Location = MPosition
  27.         End If
  28.     End Sub
  29.  
  30.     Private Sub btnMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseUp
  31.         If Dragging Then
  32.             'end the dragging
  33.             Dragging = False
  34.             'Me.Capture = False
  35.             Cursor.Clip = Nothing
  36.             btnMove.Invalidate()
  37.         End If
  38.     End Sub
Oct 2 '08 #2
This is how you move the control around on the form. just changed the btnMove to the name of the control that you want to be able to move.

Expand|Select|Wrap|Line Numbers
  1. Inherits System.Windows.Forms.Form
  2.     Public Dragging As Boolean
  3.     Public mousex, mousey As Integer
  4.  
  5. Private Sub btnMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseDown
  6.         If e.Button = MouseButtons.Left Then
  7.             Dragging = True
  8.             mousex = -e.X
  9.             mousey = -e.Y
  10.             Dim clipleft As Integer = Me.PointToClient(MousePosition).X - btnMove.Location.X
  11.             Dim cliptop As Integer = Me.PointToClient(MousePosition).Y - btnMove.Location.Y
  12.             Dim clipwidth As Integer = Me.ClientSize.Width - (btnMove.Width - clipleft)
  13.             Dim clipheight As Integer = Me.ClientSize.Height - (btnMove.Height - cliptop)
  14.             Cursor.Clip = Me.RectangleToScreen(New Rectangle(clipleft, cliptop, clipwidth, clipheight))
  15.             btnMove.Invalidate()
  16.         End If
  17.     End Sub
  18.  
  19.     Private Sub btnMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseMove
  20.         If Dragging Then
  21.             'move control to new position
  22.             Dim MPosition As New Point()
  23.             MPosition = Me.PointToClient(MousePosition)
  24.             MPosition.Offset(mousex, mousey)
  25.             'ensure control cannot leave container
  26.             btnMove.Location = MPosition
  27.         End If
  28.     End Sub
  29.  
  30.     Private Sub btnMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseUp
  31.         If Dragging Then
  32.             'end the dragging
  33.             Dragging = False
  34.             'Me.Capture = False
  35.             Cursor.Clip = Nothing
  36.             btnMove.Invalidate()
  37.         End If
  38.     End Sub
i dont mean to move element i can do it using drag and drop
but i need special kind of control to use it as text box to insert text inside it and that box can be moved and resize :$

thank u for ur answer i appreciate that :)
Oct 2 '08 #3
joedeene
583 512MB
i believe user controls are resizable in the designer view on visual studio?

joedeene
Oct 2 '08 #4
i believe user controls are resizable in the designer view on visual studio?

joedeene
u are right
i need control to be resizable also when my program running :$
not only in the designer view :)

thank u joedeene
:)

plz help me :$
Oct 3 '08 #5
Curtis Rutland
3,256 Expert 2GB
Well, build on what you know. Now that you know how to move a control, instead of changing the position, change the size.
Oct 3 '08 #6
Well, build on what you know. Now that you know how to move a control, instead of changing the position, change the size.
mmmm
i know how can i resize it using code
but i need to do using mouse ...

i hope what i mean is clear
:$

thank u nsertAlias :)
Oct 3 '08 #7
joedeene
583 512MB
mmmm
i know how can i resize it using code
but i need to do using mouse ...

i hope what i mean is clear
:$

thank u nsertAlias :)
ok bud, now that, i think, i get what you're trying to accomplish perhaps a link like THIS ONE, and just a simple google search such as "how to make resizable controls at runtime", thats how i found the link. well ok.. let me know if thats what you were looking for...

joedeene
Oct 3 '08 #8
Curtis Rutland
3,256 Expert 2GB
You will have to use code to do the resizing. But you can adapt the code for dragging a control into code for resizing. You have to change size instead of location.
Oct 3 '08 #9
ok bud, now that, i think, i get what you're trying to accomplish perhaps a link like THIS ONE, and just a simple google search such as "how to make resizable controls at runtime", thats how i found the link. well ok.. let me know if thats what you were looking for...

joedeene

yes
.....that what i want :)
but instead of picture i need text-box...and i need it in c#

than u very much
Oct 5 '08 #10
joedeene
583 512MB
yes
.....that what i want :)
but instead of picture i need text-box...and i need it in c#

than u very much
well, they say that code works for any code

picturebox named pbDemo in this example, but it could be any control),
And well, make an attempt to convert the code yourself, and when you run into stumbles, post the part you cannot convert and we will help you...

joedeene
Oct 5 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
4
by: Ryan Ternier | last post by:
Hello, I have a repeater control that does the following on the ItemDataBound event. It works perfectly, except that when it prints out, the names of the controls aren't what I'd expect. ...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
9
by: Charts | last post by:
I use VS2005 to build a asp.net 2.0 project. I want to be able to click a button on the page and have a dialog window appear where I can navigate the folders to get hold of a file path to load...
0
by: nate | last post by:
the error returned is this: Server Error in '/AnnAccRpt' Application. -------------------------------------------------------------------------------- Could not find control 'DropDownList1' in...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.