artem_niko Posted February 29, 2020 Share Posted February 29, 2020 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, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 29, 2020 Share Posted February 29, 2020 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. Quote Link to comment Share on other sites More sharing options...
artem_niko Posted March 2, 2020 Author Share Posted March 2, 2020 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 2, 2020 Share Posted March 2, 2020 22 minutes ago, Артем said: On this row: if ACol = UniMainModule.tempFD.FieldByName('R11F06').AsString then if ACol = UniMainModule.tempFD.FieldByName('R11F06').AsInteger then ? Quote Link to comment Share on other sites More sharing options...
artem_niko Posted March 2, 2020 Author Share Posted March 2, 2020 Just now, Sherzod said: if ACol = UniMainModule.tempFD.FieldByName('R11F06').AsInteger then ? Replaced. But...cells not colored. Quote Link to comment Share on other sites More sharing options...
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.