Jump to content

Colored UniDBGrid by finded values


artem_niko

Recommended Posts

So, the question is about the capabilities of UniDBGrid.

What is:

There is a table in the database. This table has one field in which a list of certain values is stored.The project has a UniDBGRid with values.

What should be done:

It is necessary, having received the values from the database table, for example, in the form of a list (I will do this), check UniDBGrid for the existence of these values in the table and highlight the cells where these values are found from the list received from the database. I understand that UniDBGRid does not contain data, but only displays them. It stores data in a DataSet to which UniDBGRid is connected.

The question is how to reconcile with DataSet in UniDBGrid and highlight cells with found texts with some color? Something like, "go through each UniDBGrid column and check the value in it with a list of values from,

Link to comment
Share on other sites

14 minutes ago, Артем said:

The question is how to reconcile with DataSet in UniDBGrid and highlight cells with found texts with some color? Something like, "go through each UniDBGrid column and check the value in it with a list of values from,

If I understand you correctly, you can use OnDrawColumnCell event:

\FMSoft\Framework\uniGUI\Demos\Desktop\GridCellStyle

You can find many examples on the forum.

Link to comment
Share on other sites

On 2/29/2020 at 11:42 PM, Sherzod said:

If I understand you correctly, you can use OnDrawColumnCell event:


\FMSoft\Framework\uniGUI\Demos\Desktop\GridCellStyle

You can find many examples on the forum.

I was see demo...and I was try write code as I need:

procedure TUniFrameM1.UniDBGridUsersOfProjectDrawColumnCell(Sender: TObject;
  ACol, ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin
  UniMainModule.tempFD:=TFDQuery.Create(nil);
  UniMainModule.tempFD.Connection:=UniMainModule.FDConnection;
  UniMainModule.tempFD.SQL.Text:='SELECT MyField FROM TestTable WHERE (Field1=2) AND (Field2='')';
  UniMainModule.tempFD.Open;
  while not UniMainModule.tempFD.Eof do
  begin
    if ACol = UniMainModule.tempFD.FieldByName('MyField').AsString then
    begin
      Attribs.Color:=clRed;
    end;
    UniMainModule.tempFD.Next;
  end;
  FreeAndNil(UniMainModule.tempFD);
end;

Then I want use event in UniDBGrid that check. If getted values from field MyField exist in UniDBGrid then make cell clRed.

But I get error:

[dcc32 Error] UnitFrameM1.pas(1157): E2010 Incompatible types: 'string' and 'Integer'

On this row: 

if ACol = UniMainModule.tempFD.FieldByName('R11F06').AsString then

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...