Forum > Beginners
StringGrid Clear? (solved!!!)
pentilisea:
Hi again,
getting along with StringGrid fine although...
I configured StringGrid1 with the Object Inspector
The StringGrid displays my diverse calculation. All good.
Before loading next file I clear all Edits and so on.
When I do StringGrid1.Clear, it clears fine, but I can't
restore the original settings I did with Object Inspector.
The following lines leaves the first row0 (?) with titles ok,
loding new file OK, but it does not write again the results into
Row 1 - etc...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---for c := spins downto 0 do begin StringGrid1.DeleteRow(1); StringGrid1.Refresh; end;
The Grid is configured to have 100 rows to start with.
Well, how do I clear,clean or empty the written rows and start
again with the original code? (which of course fails after a StringGrid1.Clear event)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- StringGrid1.Cells[1, spins] := Edit1.text; StringGrid1.Cells[2, spins] := inttostr(spins); StringGrid1.Cells[3, spins] := IntToStr(beton); StringGrid1.Cells[4, spins] := IntToStr(wager); StringGrid1.Cells[5, spins] := IntToStr(loss); StringGrid1.Cells[6, spins] := IntToStr(win); StringGrid1.Cells[7, spins] := IntToStr(budget); StringGrid1.Cells[8, spins] := mode; StringGrid1.Cells[9, spins] := Label1.Caption; StringGrid1.Refresh;
Thanks for your consideration and time.
For better understanding see attachments.
Klaus
jamie:
If I understand correctly, you should look at the CLEAN options in the string grid.
There a few to choose from.
you can selectively clean out the cells you want and leave all others.
dsiders:
--- Quote from: jamie on March 11, 2023, 03:14:59 pm ---If I understand correctly, you should look at the CLEAN options in the string grid.
There a few to choose from.
you can selectively clean out the cells you want and leave all others.
--- End quote ---
https://dsiders.gitlab.io/lazdocsnext/lcl/grids/tcustomstringgrid.clean.html
pentilisea:
Thanks,
I wrote 5 rows into the grid.
Did StringGrid1.Clean([]);
It leaves title row intact.
It cleans out the 5 rows OK, but then restarts at row 6, although assignet to write row 1 ...
Sorry I'm not getting the syntax with all the other stuff correctly done.
Klaus
dsiders:
--- Quote from: pentilisea on March 11, 2023, 07:33:25 pm ---Thanks,
I wrote 5 rows into the grid.
Did StringGrid1.Clean([]);
It leaves title row intact.
It cleans out the 5 rows OK, but then restarts at row 6, although assignet to write row 1 ...
Sorry I'm not getting the syntax with all the other stuff correctly done.
Klaus
--- End quote ---
If Clear and Clean do not meet your needs, just use RowCount and ColCount to truncate the grid to the size you want.
Navigation
[0] Message Index
[#] Next page