Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

incorporating the path of the file that will be displayed in the listbox

Posted on 2003-10-25
2
Medium Priority
?
174 Views
Last Modified: 2011-09-20
Hi, how can we incorporate the path of a file that will be added to the listbox
without having it to be displayed in the listbox.. example>
what i want is that in the list box it will display

z21001.zip but it carries the path of this file silently..

and not this one

c:\progra~1\z21001.zip


in the list its just z21001.zip.. hope you understand.. thanks





0
Comment
Question by:orafans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9619219
Either:
1. Have a seperate string list which stores the full path
2. Use OwnerDraw so that you draw the item yourself - internally it would be stored with the path but when you display it, just draw ExtractFileName(path).

Example for 2:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect:TRect;State: TOwnerDrawState);
begin
      with (Control as TListBox).Canvas do  { draw on control canvas, not on the form }
      begin
            FillRect(Rect);       { clear the rectangle }
            TextOut(Rect.Left, Rect.Top, ExtractFileName((Control as TListBox).Items[Index]))
      end;
end;

Geoff M.
0
 
LVL 4

Accepted Solution

by:
nestorua earned 500 total points
ID: 9619571
HI,
You can do it the following way (very useful indeed):

TYPE
 TPathStr=class
   FullPath: string;
    constructor Create(AFullPath: string);
  end;

{ TMyStr }
constructor TPathStr.Create(AFullPath: string);
begin
 Inherited Create;
 FullPath:=AFullPath;
end;

procedure TForm1.AddItemToListBox(FileName: string);
begin
 with ListBox1.Items do
    AddObject(ExtractFileName(FileName), TPathStr.Create(FileName));
end;
Sincerely,
Nestorua.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question