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

Shapes of textboxes

Parul Bagadia
188 100+
can we have some other shapes of text boxes? or even of labels?
I want to write in curve mode or zigzag type format?
Is there any property or sth by which i can get this?
Oct 12 '08 #1
7 1399
debasisdas
8,127 Expert 4TB
no there is no such property . Try use some third party control if you can find.
Oct 13 '08 #2
Parul Bagadia
188 100+
what do you mean by third party control?
Oct 19 '08 #3
jg007
283 100+
This is only very basic and I have pathced it together from a few googles so you can probably get something better but -

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Form1
  3.  
  4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.         Dim test As New fancytext
  6.         test.Multiline = True
  7.         test.Text = vbCrLf & "      Oval textbox! "
  8.         Dim p As Graphicspath = New GraphicsPath
  9.         Dim reg As Region
  10.         Dim sf As New StringFormat
  11.         p.AddEllipse(10, 0, 80, 50) '
  12.         reg = New Region(p)
  13.         Me.Controls.Add(test)
  14.         test.Region = reg
  15.         test.Location = New System.Drawing.Point(30, 30)
  16.  
  17.     End Sub
  18.  
  19.     Public Class fancytext
  20.         Inherits RichTextBox
  21.  
  22.     End Class
  23. End Class
  24.  
  25.  
  26.  
Oct 19 '08 #4
jg007
283 100+
and just out of curiosity here is some code to create 2x oval buttons, it took a bit of time to work out how to get them to handle a click though :)


it was quite a bit of playing to get these to work and the textbox is quite awkward as the code I have above means that if you actually try to type into it you cannot see any text that is entered outside the boundarys so as sugested you are probably better finding a control that had been written by somebody else and then you can just add it to you project in the same way as an ordinary textbox

Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Drawing.Drawing2D
  3. Imports System
  4. Imports System.Drawing.Text
  5. Imports System.Drawing
  6. Public Class Form1
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.         Dim test As New fancytext("Test")
  10.         Dim test2 As New fancytext("Test2")
  11.         ' test.Multiline = True
  12.         Dim p As GraphicsPath = New GraphicsPath
  13.         Dim reg As Region
  14.         Dim sf As New StringFormat
  15.         p.AddEllipse(5, 20, 80, 50) '
  16.         reg = New Region(p)
  17.  
  18.         Me.Controls.Add(test)
  19.         test.Text = vbCrLf & "Click me!"
  20.         test.Location = New System.Drawing.Point(20, 20)
  21.         test.Size = New System.Drawing.Size(90, 80)
  22.         test.Region = reg
  23.  
  24.         Me.Controls.Add(test2)
  25.         test2.Text = vbCrLf & "Click me!"
  26.         test2.Location = New System.Drawing.Point(100, 20)
  27.         test2.Size = New System.Drawing.Size(90, 80)
  28.         test2.Region = reg
  29.  
  30.     End Sub
  31.  
  32.  
  33.     Public Class fancytext
  34.         Inherits Button
  35.  
  36.         Private BName As String
  37.  
  38.         Public Sub New(ByVal nam As String)
  39.             BName = nam
  40.         End Sub
  41.  
  42.         Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  43.             MyBase.OnClick(e)
  44.             MsgBox(BName)
  45.  
  46.  
  47.         End Sub
  48.  
  49.     End Class
  50.  
  51.  
  52. End Class
  53.  
  54.  
Oct 19 '08 #5
jg007
283 100+
,yeah yeah I know.. I just realised that I didn't really need to create a new class and could have just changed the region on an existing control <:)

I will leave the code there though as it could probably be amended fairly easily to actually create a control with the preset shape

this code amends an existing label but I had to change the label to not use auto size


Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Drawing.Drawing2D
  3. Imports System
  4. Imports System.Drawing.Text
  5. Imports System.Drawing
  6. Public Class Form1
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.  
  10.  
  11.  
  12.         Dim p As GraphicsPath = New GraphicsPath
  13.         Dim reg As Region
  14.         p.AddEllipse(0, 0, 90, 50) '
  15.         reg = New Region(p)
  16.         Label1.Region = reg
  17.         Label1.Text = "test"
  18.         Label1.BackColor = Color.Azure
  19.         Label1.Size = New System.Drawing.Size(100, 60)
  20.         Label1.AutoSize = False
  21.         Label1.TextAlign = ContentAlignment.MiddleCenter
  22.  
  23.  
  24.     End Sub
  25.  
  26.  
Oct 19 '08 #6
jg007
283 100+
lol, gonna have to thank you as I have found a few interesting things trying to answer this.

for a star shaped button -

Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Drawing.Drawing2D
  3. '
  4. Public Class Form1
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Dim xPoints As Integer() = {55, 67, 109, 73, 83, 55, 27, 37, 1, 43}
  8.         Dim yPoints As Integer() = {0, 36, 36, 54, 96, 72, 96, 54, 36, 36}
  9.         Dim brush As SolidBrush = New SolidBrush(Color.DarkMagenta)
  10.  
  11.  
  12.         Dim p As GraphicsPath = New GraphicsPath
  13.         Dim reg As Region
  14.         For i = 0 To 8 Step 2
  15.             p.AddLine(xPoints(i), yPoints(i), xPoints(i + 1), yPoints(i + 1))
  16.         Next
  17.  
  18.  
  19.         reg = New Region(p)
  20.         Button1.Image = Nothing
  21.  
  22.         Button1.Region = reg
  23.         Button1.Text = " Click "
  24.         Button1.BackColor = Color.Azure
  25.         Button1.Size = New System.Drawing.Size(110, 105)
  26.         Button1.AutoSize = False
  27.  
  28.         Button1.TextAlign = ContentAlignment.MiddleCenter
  29.  
  30.  
  31.  
  32.     End Sub
  33.  
  34.  
  35. End Class
  36.  
  37.  
Oct 19 '08 #7
debasisdas
8,127 Expert 4TB
what do you mean by third party control?
you need to use componenets from vendors other than MS.
Oct 19 '08 #8

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

Similar topics

3
by: mf_sina | last post by:
Hi all! I have worked eith vb 6 and used custom shapes such as circle,elipse,Rectangle and ... But these shapes are not in vb .net? How can i get them? Best wishes...
0
by: Mats-Lennart Hansson | last post by:
Hi, I'm creating some user controls that are in different shapes. When doing this I use this.region to set the shape that I want and then I use graphics.DrawRectangle (or whatever shape I have) to...
3
by: Crirus | last post by:
There are some classes to reproduce geometrical shapes like circles or squares? as there is rectangle -- Cheers, Crirus ------------------------------ If work were a good thing, the boss...
1
by: Andreas Schubert | last post by:
Hello newsgroup, I am pretty new to .NET and need some advise on how to approach to the following: I have to create an application with a drawing surface, where some predefined shapes...
0
by: excelthoughts | last post by:
Hi, In VBA, you can select shapes and control them using Selection.ShapeRange. There is no equivalent in C#. See...
6
by: Kristian Frost | last post by:
Hi, I'm trying to add, as you might guess, mouseclick listeners to the shapes I am drawing using the GDI+ commands in a similar sort of way as could be done with the old VB "shapes". Problem is,...
0
by: alwayssmiling | last post by:
Hi, Im drawing some shapes on the image surface (i.e when im displaying the image ) with the help of graphics. Since i want to move thsese shapes from one place to other place in the...
0
by: weird0 | last post by:
i have successfully emebedded visio drawing tool in my application. Infinite number of shapes can be added to the drawing. How can i write double click event handler for the the shapes added to...
4
by: Sunny | last post by:
Hi I have a div called shape on my page. When I try to get its length using javascript in IE, everything works fine. But When I try it in Firefox it has element has no properties. Here is the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.