Solved

Hide cols in TStringGrid

Posted on 1997-03-30
5
662 Views
Last Modified: 2010-05-18
Is it possible to have hidden columns in a TStringGrid? If not, what is the best way to store a list of records when you only want to show some fields of the records to the user? (BTW these 'records' are not database records - they are being read from a binary file.) This list will be read-only so there is no requirement for the user to be able to edit the records.
0
Comment
Question by:ChrisGin
[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
  • 2
5 Comments
 

Accepted Solution

by:
boabyte earned 25 total points
ID: 1335074
There are two possible solutions, depending upon your need to
access the data.

1. If there is no need to cross-reference data, just update
   the string grid with the fields you want shown.

2. If you do need to cross-reference data: Create a dynamic
   mutlidimensional array. (this is if all fields can be
   converted to string types.) Then read info from binary file
   into array. This allows you to show only certain fields, but
   still allows cross-reference of fields.
0
 

Author Comment

by:ChrisGin
ID: 1335075
I do have the complete set of data in an array, and I want my TStringGrid to only show one or two fields. That's fine, however to link the items in the grid with the items in the array, I need to store another field (the array index) in the grid, but I don't want the user to see it.

At the moment it's not a problem because the grid is never sorted (and therefore the index in the grid is the same as the index in the array) but that may change.....
0
 

Expert Comment

by:boabyte
ID: 1335076
Could you use the StringGrid.Cells(Col,Row) or StringGrid.Row
property to use as the StringGrid index?
0
 

Author Comment

by:ChrisGin
ID: 1335077
Yes that works as long as I never sort the grid. But let's say the grid is in random order and there is no way to link the grid items back to the array without storing the array index in the grid. Can I perhaps add the extra field to the grid and set its column width to 0? Is there another 'list' control which would be better suited to what I'm trying to do?
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335078
I think BoaBytes answer is just fine.  What if you COULD store your data in a few 'invisible' columns and you then performed a sort...wouldn't you still have a need to store the references to the invisible data, since a sort would change their column location?

You mentioned setting column width to 0, like you had yet to try that.  Try it.

Why don't you simply update the references to the columns during the sort?  I've done something similar and it is not too tough.

Another option is to use OLE and link in an Excel table...with that you'll get all the functionality of Excel.  StringGrid is ot Excel, it will not come with all the functionality you desire.  Either develop workarounds, as BoaByte has suggested, or go to the Delphi Super Page and find one of the many grid components that will do exactly what you wish.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 168
Delphi and Access based Enumeration 9 78
how to change, disabled button color FMX ? 1 51
firemonkey keyboard covers the controls 1 53
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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