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

Creating a LinkLabel Programmatically

Can someone please help with a problem that I'm having? I'm trying to create
a linklabel in VB.NET 2003 at runtime when a user clicks a button. The app
looks in a path for .doc and .pdf files and creates a linklabel for each file
name. When running the app the first name is being created but only portions
of the string is showing; and also it looks like the remaining is being
created but I can't see them it's like their cut off. Here is the code from
the button's click event:

Dim strPath As String = txtDirectory.Text.ToString()
Dim strTemp, strFile As String
Const intX As Integer = 16
Dim intY As Integer = 8
Const intHeight As Integer = 16
Const intWidth As Integer = 100
Dim intX2 As Integer = 0
Dim i As Integer

For Each strFile In Directory.GetFiles(strPath)
If Path.GetExtension(strFile).ToLower = ".doc" Or
Path.GetExtension(strFile).ToLower = ".pdf" Then
strTemp = Path.GetFileName(strFile)

Dim myLinkLabel As New LinkLabel
With myLinkLabel
.Name = "lnkLabel_" & i.ToString()
.Visible = True
.ActiveLinkColor = Color.Red
.DisabledLinkColor = Color.Blue
.LinkColor = Color.Blue
.VisitedLinkColor = Color.Purple
.Text = strTemp
End With
plMain.Controls.Add(myLinkLabel)

End If
i += 1
Next

I'm trying to set the Location.X for each created LinkLabels but VB is not
liking it. It's telling me that an integer can not be a system.drawing.point
type. What am I doing wrong?

--
TC
Apr 11 '06 #1
2 3013
Hi,
When running the app the first name is being created but only portions
of the string is showing; and also it looks like the remaining is being
created but I can't see them it's like their cut off.
I was working on a similar app sometime back and was facing similar
problems. Seemed to work fine, when I set the AutoSize and LinkArea
properties correctly. (Set AutoSize to True.)
I'm trying to set the Location.X for each created LinkLabels but VB is not
liking it. It's telling me that an integer can not be a system.drawing.point
type.


You mustn't try to set the X or Y properties of the Location Property
(See "Control.Location" in MSDN help for the explanation). Instead set
it's Location to a new Point() as :

myLinkLabel.Location = New Point(intX * i, intY * i)

where i can be incremented with each label.

Hope this helps,

Regards,

Cerebrus.

Apr 11 '06 #2
Thanks Cerebrus for the help.
--
TC
"Cerebrus" wrote:
Hi,
When running the app the first name is being created but only portions
of the string is showing; and also it looks like the remaining is being
created but I can't see them it's like their cut off.
I was working on a similar app sometime back and was facing similar
problems. Seemed to work fine, when I set the AutoSize and LinkArea
properties correctly. (Set AutoSize to True.)
I'm trying to set the Location.X for each created LinkLabels but VB is not
liking it. It's telling me that an integer can not be a system.drawing.point
type.


You mustn't try to set the X or Y properties of the Location Property
(See "Control.Location" in MSDN help for the explanation). Instead set
it's Location to a new Point() as :

myLinkLabel.Location = New Point(intX * i, intY * i)

where i can be incremented with each label.

Hope this helps,

Regards,

Cerebrus.

Apr 11 '06 #3

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

Similar topics

0
by: Max | last post by:
Suppose we have an object hierarchy in XSD. For example, let us take Control, Label, TextBox and LinkLabel windows controls. Each control has some properties which are represented as elements....
0
by: tota | last post by:
i'm using windowsApplication to connect to DB made by SQL i need to Display the Data of the first table in the DB as links when click it it openes a table and i navigte between them using buttons...
1
by: gabe | last post by:
I am looking for a way to mimic some of the functionality of a web page without writing html (or I am looking to someone to point out something really obvious that I am over looking) Currently I...
1
by: Joshua Ellul | last post by:
Hi There, I'm trying to create a link label dynmically. The problems I'm having is the following: 1. The LinkLabel is created without the underline 2. The click event is not being raised... ...
3
by: vince | last post by:
Hello, I have a ListBox filled with many lines of simply text I want to make few lines be a LinkLabel How can I do this Thanks
0
by: Suz | last post by:
I am stumped! I can't seem to figure out how to put a linklabel in a datagrid on a windows form. I have working code that displays a linklabel in edit mode but need the linklabel to display during...
1
by: Marcus Kwok | last post by:
I am having problems getting my LinkLabel hyperlink to work properly. Every time I click on it, I get the following exception: System.ComponentModel.Win32Exception: The requested lookup key was...
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
2
by: prokopis | last post by:
am using c# for windows applications. am using dynamic linklayer array to print some labels in the form.i get some data from the database i add them in the linklabel array and i print it on 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:
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
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?
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
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,...

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.