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

Create LinkLabels At Runtime and Configuring the LabelBox

I have a problem I was hoping someone can help me with. My first problem is
moving a link label that is created at runtime to the of an arraylist on the
next line in the listbox. Currently, the Close link is showing up on the
first line and covering up the file names when the box is populated. Here is
the code:

Dim docArray As New ArrayList() 'create an arraylist to hld the documents.
Dim strDirectory = ConfigurationSettings.AppSettings("cad_directory")

Dim objLinkClose As New System.Windows.Forms.LinkLabel 'create new linklabel
With objLinkClose
.Name = "lnkClose"
.Text = "Close"
End With

Dim strFile As String

For Each strFile In Directory.GetFiles(strDirectory) 'get the files
in the directory
If Path.GetExtension(strFile) = ".doc" Or
Path.GetExtension(strFile) = ".pdf" Then
Dim strTemp As String = Path.GetFileName(strFile)
docArray.Add(strTemp)
End If
Next

'If no files are found then inform the user through the listbox.
If docArray.Count() = 0 Then
Dim strTmp As String = "No Files to Display.......!"
docArray.Add(strTmp)
End If
lbdocs.DataSource = docArray
Me.lbdocs.Controls.Add(objLinkClose)

Secondly, I need to make the file names that are returned linklabels also;
so that when a user clicks on one it opens up the file in WORD or PDF(that's
the plan so far). So, any help would greatly be appreciated.
--
TC
Feb 17 '06 #1
1 1285
DWS
Terrance your off to a great start.

search for system.diagnostics.process.start in msdn library. When checking
the file extention add a .tolower to guarantee a match with odd case.
Path.GetExtension(strFile).tolower = ".pdf"

Good Luck
DWS
"Terrance" wrote:
I have a problem I was hoping someone can help me with. My first problem is
moving a link label that is created at runtime to the of an arraylist on the
next line in the listbox. Currently, the Close link is showing up on the
first line and covering up the file names when the box is populated. Here is
the code:

Dim docArray As New ArrayList() 'create an arraylist to hld the documents.
Dim strDirectory = ConfigurationSettings.AppSettings("cad_directory")

Dim objLinkClose As New System.Windows.Forms.LinkLabel 'create new linklabel
With objLinkClose
.Name = "lnkClose"
.Text = "Close"
End With

Dim strFile As String

For Each strFile In Directory.GetFiles(strDirectory) 'get the files
in the directory
If Path.GetExtension(strFile) = ".doc" Or
Path.GetExtension(strFile) = ".pdf" Then
Dim strTemp As String = Path.GetFileName(strFile)
docArray.Add(strTemp)
End If
Next

'If no files are found then inform the user through the listbox.
If docArray.Count() = 0 Then
Dim strTmp As String = "No Files to Display.......!"
docArray.Add(strTmp)
End If
lbdocs.DataSource = docArray
Me.lbdocs.Controls.Add(objLinkClose)

Secondly, I need to make the file names that are returned linklabels also;
so that when a user clicks on one it opens up the file in WORD or PDF(that's
the plan so far). So, any help would greatly be appreciated.
--
TC

Feb 17 '06 #2

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

Similar topics

5
by: Patrick Marti | last post by:
I wish to create some LinkButtons in DotNet. Because I will do it in dependence of the entries in a database, I can not add them with the mouse to the form as usually. I can create them in the...
8
by: Steve Neill | last post by:
Can anyone suggest how to create an arbitrary object at runtime WITHOUT using the deprecated eval() function. The eval() method works ok (see below), but is not ideal. function Client() { }...
0
by: HamuNaptra | last post by:
Hi, I have a form which contains more than 15 linklabels, all of them have a transparant backcolor. The form itself has a backgroundimage. Now when I show the form, it takes a moment to...
0
by: Wajih | last post by:
I have a list view. I want to insert LinkLabels dynamically in it as ListViewSubItems. Is it possible to do this? If yes, how should i do it. If no, are there any workarounds. Thanx and regards
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
1
by: | last post by:
This is a crosspost from a less-frequented (but more focused) asp.net group; I didn't receive an answer that worked. I'd like to get this form functional. Could someone help on what's probably a...
0
by: Terrance | last post by:
Hello, I was wondering if anyone can help me. I have some code where I'm creating linklabels during runtime using filenames that in a directory. I created a LinkClicked event but it only launches...
1
by: rada.lambretha | last post by:
Configuring Linux as a Firewall * Making installation choices * Introducing iptables * Using iptables commands * Simplifying things with firewall GUIs * Adding proxy functionality As...
4
by: Axel Dahmen | last post by:
Hi, I've created a few simple console tools. No .NET used at all, just STL. Now I want to just XCOPY them to another machine. But running them there yields a couple of errors in the application...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.