473,799 Members | 3,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a LinkLabel Programmaticall y

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.Te xt.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.GetFi les(strPath)
If Path.GetExtensi on(strFile).ToL ower = ".doc" Or
Path.GetExtensi on(strFile).ToL ower = ".pdf" Then
strTemp = Path.GetFileNam e(strFile)

Dim myLinkLabel As New LinkLabel
With myLinkLabel
.Name = "lnkLabel_" & i.ToString()
.Visible = True
.ActiveLinkColo r = Color.Red
.DisabledLinkCo lor = Color.Blue
.LinkColor = Color.Blue
.VisitedLinkCol or = Color.Purple
.Text = strTemp
End With
plMain.Controls .Add(myLinkLabe l)

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 3058
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.Locati on" in MSDN help for the explanation). Instead set
it's Location to a new Point() as :

myLinkLabel.Loc ation = 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.Locati on" in MSDN help for the explanation). Instead set
it's Location to a new Point() as :

myLinkLabel.Loc ation = 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
5084
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. Some of the elements are of complex types as well, like bounds - of type rectangle. (See full example in the bottom of the letter.) DataSet.ReadXMLSchema fails to parse such XSD file. The problem is caused by complex type as an element of the...
0
1895
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 my problem is that i need to make the retrieved data as links (similar to objectList in Mobile application) i used LinkLabel to make an array of LinkLabels for (int n=0 ; i<j ; i++) {
1
5328
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 read out some data into a dataset then appending it to a richtextbox. So far so good. Some of the fields that I append are paths to documents. I would like to be able to click on the paths (like a hyperlink) I am able to create a linklabel at...
1
3749
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... Here's my code: Dim newLink As New LinkLabel()
3
12032
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
1268
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 the initial datagrid load. I am working with datagridcolumnstyles. I have looked at combobox examples, etc but can't seem to extrapolate. Any help appreciated! Thanks!
1
1746
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 not found in any active activation context at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at...
3
4698
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 form that has the System.Windows.Forms.LinkLabel controls on it is in a different project and under a different namespace from the file where the LinkLabel_LinkClicked events are, so I can't just do frm.ShowDialog under the LinkClicked method. ...
2
2141
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 screen. my problem is how to make that linklabel to work when i select the label.am using the code below but is not working:) public class Form1 : Form { System.Windows.Forms.LinkLabel linklabel;
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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
10490
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...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
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
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.