MOGSY Posted December 27, 2019 Share Posted December 27, 2019 Hi How can we change the column width dynamicaly, depending on the content of the first row. Is it possible to hide a column depending on data in the column? if uniStringGrid1.Cells[thisColumn, 1] = 'Test Data' then begin strgCars.Columns[thisColumn].Width := 0 else strgCars.Columns[thisColumn].Width := 100; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 27, 2019 Share Posted December 27, 2019 4 minutes ago, MOGSY said: How can we change the column width dynamicaly, depending on the content of the first row. Is it possible to hide a column depending on data in the column? Hi, Can you please explain in more detail? uniStringGrid1, strgCars - What kind of control, and how are they related? Quote Link to comment Share on other sites More sharing options...
MOGSY Posted December 27, 2019 Author Share Posted December 27, 2019 sorry for spelling error. I would like to hide some column in string grid either by setting the width to zero or any other suggestion. if uniStringGrid1.Cells[thisColumn, 1] = 'Test Data' then begin uniStringGrid1.Columns[thisColumn].Width := 0 else uniStringGrid1.Columns[thisColumn].Width := 100 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 27, 2019 Share Posted December 27, 2019 Also this post may help: http://forums.unigui.com/index.php?/topic/11709-how-do-i-validate-a-value-from-a-stringgrid/&do=findComment&comment=62231 Quote Link to comment Share on other sites More sharing options...
MOGSY Posted December 27, 2019 Author Share Posted December 27, 2019 Hi Thanks for the link, i have tried it but I do not receive the _edit event. What I would like to do is check the second row data on each column "ignoring the title row" and if it has no data, then I would like to hide that column. I was thinking if I could set the width of the column to zero then the column is hiden. This works in delphi. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 27, 2019 Share Posted December 27, 2019 2 hours ago, MOGSY said: Thanks for the link, i have tried it but I do not receive the _edit event. Hi, Can you make a simple testcase for check? Quote Link to comment Share on other sites More sharing options...
MOGSY Posted December 27, 2019 Author Share Posted December 27, 2019 6 hours ago, Sherzod said: Hi, Can you make a simple testcase for check? procedure TFrameTesting.strgDrawCell(Sender: TObject; ACol, ARow: Integer; var Value: string; Attribs: TUniCellAttribs); var S,aStat : string; begin S:=TUniStringGrid(Sender).Cells[ACol, ARow]; Attribs.Font.Size := 12; if aRow = 0 then Attribs.Font.Size := 10 else begin aStat := getStatus(S); if aStat = 'CLN' then begin Attribs.Font.Color:=clYellow; Attribs.Font.Style:=[fsBold]; end else if aStat = 'CLR' then begin Attribs.Font.Color:=clGreen; end else if aStat = 'RES' then begin Attribs.Font.Color:=clGray; end else if aStat = 'POG' then begin Attribs.Font.Color:=clRed; end else if aStat = 'SOL' then begin Attribs.Font.Color:=clBlue; end else begin (sender as TUniStringGrid).Columns[ACol].Width := 0; end; end; end; Quote Link to comment Share on other sites More sharing options...
MOGSY Posted December 29, 2019 Author Share Posted December 29, 2019 Is there any way of hiding columns in stringgrid? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 29, 2019 Share Posted December 29, 2019 On 12/27/2019 at 6:59 PM, MOGSY said: Thanks for the link, i have tried it but I do not receive the _edit event. Make a simple testcase for check. Quote Link to comment Share on other sites More sharing options...
MOGSY Posted December 30, 2019 Author Share Posted December 30, 2019 Please find attached a testcase. Test.7z 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.