Recent

Author Topic: Using TListbox: How to add columns?  (Read 9401 times)

khf

  • New Member
  • *
  • Posts: 10
Using TListbox: How to add columns?
« on: December 18, 2010, 04:20:18 pm »
Hi Boys & Girls!  :P

I am working with a binary file where i store only a record variable

Code: [Select]
people = record
name:array[1..20] of char;
lastName:array[1..20] of char;
etc
...
end;

The idea is to have a little data base in this binary file. The work is in progress, and untill now, the program can write data into the file, and i have some data in a test file, but now i have a big problem: ¿how can I access the data in the file?
-> I made a "search!" button that searches in the file for people's name, then it displays the matches in a listbox (so the user can select the name he is searching for and then the program would display the whole information the user wants).

But.... what if there are two or more people that have the same name?
That's the reason why I want to display on my listbox the name, the last name and maybe some other usefull information in different columns.

I've tried searching on internet, and i found a topic that says that i have to use this two different commands
Code: [Select]
^I
^|
But it doesn't works.

Source (check the second reply to view the example code)
Code: [Select]
http://www.clubdelphi.com/foros/showthread.php?t=17580


Also, I've tried writting
Code: [Select]
ListBox1.Items.and checked the pop up menu searching for any clues, but I didn't understood it very well.

It's the first time I'm working with Lazarus, before that, the only OOP I worked with was Visual Basic. I have "self-learned" the OOP... so my knowledges may not be so polished

By last, sorry for my english mistakes, i hope you understood my problem.

cheers!
 :-*

PS: Second question...
If i select an item from the listbox.... how can i know what item i've selected? (the first item, the second item, etc?) I mean: whenever i select an item, is there a "index" property of the listbox that changes?
PS(2):Second question Solved by myself:
Use ListBox1.ItemIndex to know the selected item number
« Last Edit: December 18, 2010, 05:23:38 pm by khf »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Using TListbox: How to add columns?
« Reply #1 on: December 18, 2010, 05:59:48 pm »
I suggest using TListView with lvsReport instead. It's cleaner for this kind of requirement.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Using TListbox: How to add columns?
« Reply #2 on: December 18, 2010, 06:26:23 pm »
The Lazarus TListbox is cross-platform, and lacks the functionality of adding columns using the Tabwidth property of Delphi (which is windows-specific).

H

khf

  • New Member
  • *
  • Posts: 10
Re: Using TListbox: How to add columns?
« Reply #3 on: December 19, 2010, 12:37:08 am »
Ok, thanks, i'll accept your suggestions...

Anyways, i have another idea to solve the problem... maybe adding one large string where i would add the name and last name of the person

 

TinyPortal © 2005-2018