joriolm Posted January 25, 2012 Posted January 25, 2012 Hi everyone, I'm trying to validate a UniStringGrid's Cell content with a number. Would be great to have OnKeyPress or OnKeyDown. Some plans to add this in next versions ? There is another workaround to do this? Thanks. Quote
Administrators Farshad Mohajeri Posted January 26, 2012 Administrators Posted January 26, 2012 You want to validate cells in OnKeyDown event? Quote
joriolm Posted January 26, 2012 Author Posted January 26, 2012 You want to validate cells in OnKeyDown event? Hi, Farshad, Well.......yes, too newbiest my request? sorry, jeje. I would like to control in a UniStringGrid cell only numbers, like in Delphi: if Key in ['0','1','2','3',.....] but this is controled by OnKeyDown and OnKeyPress of the SG, right ? Thanks by your reply. J. Oriol M. Quote
Administrators Farshad Mohajeri Posted January 27, 2012 Administrators Posted January 27, 2012 You can use OnDrawCellEvent for this. Quote
joriolm Posted March 20, 2012 Author Posted March 20, 2012 Hi Farshad. I did it like this, in case somebody needs it too. (Someone as newbie as me). Inside the DrawCell of the UniStringGrid: if (ACol = 4) and (ARow > 0) then begin Value := IntToStr(StrToIntDef(Value,0)); end; You can use OnDrawCellEvent for this. Quote
joriolm Posted March 20, 2012 Author Posted March 20, 2012 Hi, I'm still working with UniStringGrid, for some reasons not a UniDBGrid: I used OnDrawCell for coloring some columns (USG_drawed_col.png) but it takes 6 secs to navigate to another record. If I remove coloring columns in OnDrawCell, this takes less than a sec, just a blink of an eye.(USG_not_drawed_col.png) Would be good have a nice presentation with a good speed on this. Can be this fixed, please? Regards, J. Oriol M. Quote
Administrators Farshad Mohajeri Posted March 21, 2012 Administrators Posted March 21, 2012 Can be this fixed, please? It can be fixed as soon as I can reproduce it. In your pics there are only 3 records in grid. It is very unlikely to take 6 secs to move from a row to another. Can you reproduce same thing with a grid attached to a local TClientDateset? PS: Is grid in above pic a DBGrid or a StringGrid? Quote
Administrators Farshad Mohajeri Posted March 21, 2012 Administrators Posted March 21, 2012 Also, you should profile your app and find out where that 6 secs is actually spent. Quote
joriolm Posted March 23, 2012 Author Posted March 23, 2012 It can be fixed as soon as I can reproduce it. In your pics there are only 3 records in grid. It is very unlikely to take 6 secs to move from a row to another. Can you reproduce same thing with a grid attached to a local TClientDateset? PS: Is grid in above pic a DBGrid or a StringGrid? I have this config: Postgres 9 in localhost ZeosDBO 7 using a ZTable dataset for Master table. I fill in the detail data from another ZTable to the UniStringGrid by code. The filling time is not the problem, neither pass from 1 row to another row, time spend is when I scroll the UniDBNavigator to next or prior master record. Quote
Administrators Farshad Mohajeri Posted March 23, 2012 Administrators Posted March 23, 2012 I have this config: Postgres 9 in localhost ZeosDBO 7 using a ZTable dataset for Master table. I fill in the detail data from another ZTable to the UniStringGrid by code. The filling time is not the problem, neither pass from 1 row to another row, time spend is when I scroll the UniDBNavigator to next or prior master record. UniDBNavigator simply calls Next on Dataset. Since you manually fill StringGrid I need to see your code. It would be better if you send a test case created with Clientdataset. Quote
joriolm Posted March 24, 2012 Author Posted March 24, 2012 UniDBNavigator simply calls Next on Dataset. Since you manually fill StringGrid I need to see your code. It would be better if you send a test case created with Clientdataset. This is my part of code to fill in the UniStringGrid: while not(table.Eof) do begin for j:=Low(fields) to High(fields) do begin sg.Cells[j,i] := table.Fields[fields[j]].AsString; end; i:=i+1; if table.RecNo < table.RecordCount then sg.RowCount:=sg.RowCount+1; table.Next; end; I can make a test case, would you guide me with this? please? I've seen the FishFacts demo with a ClientDataset, but how can I create two tables in cds format? I don't use paradox. Quote
Administrators Farshad Mohajeri Posted March 24, 2012 Administrators Posted March 24, 2012 How many rows do you send in above loop? Quote
Administrators Farshad Mohajeri Posted March 24, 2012 Administrators Posted March 24, 2012 This is my part of code to fill in the UniStringGrid: while not(table.Eof) do begin for j:=Low(fields) to High(fields) do begin sg.Cells[j,i] := table.Fields[fields[j]].AsString; end; i:=i+1; if table.RecNo < table.RecordCount then sg.RowCount:=sg.RowCount+1; table.Next; end; UniStringGrid is not optimized for sending big number of rows in a loop. It is in todo list. I recommend using uniDBGrid anyway. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.