Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox vs Stringrid

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi. I am quite new to this and need some help..
When using a TListBox or TCheckListBox one uses ItemIndex for the selected Item. What do you use when dealing with a TStringGrid, and how do you delete the selected string row??
Hope someone can help.
 
TStringGrids allow access to their individual cells through its Cells property. For example, suppose that you have a StringGrid with 4 rows and 5 columns. To access one of the grid's cells, you could do something like:
Code:
int Column = 3; Row = 2;
String WhatIsHere = StringGrid->Cells[Column][Row];

You also have ColCount which holds the number of columns in a grid, RowCount which holds the number of rows in a grid, Rows which returns all the objects in a row, Cols which returns all the objects in a column, and Objects which also accesses cells. To copy a TStringGrid row to a TListBox you could do something like
Code:
ListBox1->Items = StringGrid1->Rows[StringGrid1->Row]
. (This example is from my help file.)

AFAIK, to "delete" a row, you would have to copy all following rows up to the previous row and blank out the last row. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Thanx! well I guess it's easier to stick with the listbox then, and just write a stringpad function. It was beacause i could not get data to be in columns in a Listbox and thought a stringgrid could be an easy way out. Cheers.
maaaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top