Jump to content

UniStringGrid validating cells


joriolm

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

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.

post-242-0-64291600-1332280013_thumb.png

post-242-0-15444900-1332280022_thumb.png

Link to comment
Share on other sites

  • Administrators

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...