Robert Meek" <[EMAIL PROTECTED]> wrote
> ...the user can alter their individual widths at runtime, I have not
> been able to find a way of storing this info back into an ini-file
> so that these settings can be retained and used again in future
> sessions.
<snip>
> because the StrGrid.Col[0] doesn't have a width property
I don't know about D2005 but StringGrids and DrawGrids in every Delphi
version that I do know have a ColWidths property.
Use this property and save each column separately.
Something like
MyIniFile.WriteInteger ('My Grid', Col0, MyGrid.colwidths[0));
MyIniFile.WriteInteger ('My Grid', Col1, MyGrid.colwidths[1));
MyIniFile.WriteInteger ('My Grid', Col2, MyGrid.colwidths[2));
One strategy for saving the cell contents to file could be something
like
With MyGrid do
For RowLoop := 0 to RowCount - 1 do
For ColLoop := 0 to ColCount - 1 do begin
S := Cells[ColLoop, RowLoop]);
MyFileStream.Write (length (S), sizeof (integer));
MyFileStream.Write (S[1], length (S));
end;
HTH
Henry Bartlett
Delphi Links Page
http://www.hotkey.net.au/~hambar/habit.delflink.htm
email: hambar at microtech dot com dot au
----- Original Message -----
From: "Robert Meek" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, March 30, 2005 5:20 PM
Subject: StringGrids D2005
Although I've done a lot of work with DBGrids I've not up until now
ever had need to use a TStringGrid, and as much as they are alike I'm
surprised at many of the differences...some of which have me a little
baffled!
For example, although one can set the columns up so that the user
can alter their individual widths at runtime, I have not been able to
find a
way of storing this info back into an ini-file so that these settings
can be
retained and used again in future sessions. Is this possible? If so
how,
because the StrGrid.Col[0] doesn't have a width property...only a
default
width that sets all of them the same including the fixed column!
Also, I was under the impression I could store a stringgrid with any
string info it's cells contain, including that in it's fixed columns,
to a
text file and then load the stringgrid back up with that same info
directly
from the file. It seems the individual column text can be saved that
way
but not all in one file. How is this handled?
Finally, Because this particular grid will be used by a restaurant
manager to set her waitress's working hours, I need to be able to
print a
copy of the grid out in landscape format after she has made all the
entries
for a particular week. I don't want a print screen because that would
show
the entire form...just the grid itself. How can this best be
accomplished?
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi