delphi - adjusting width of columns in DBGrid -
this question has answer here:
- adjust column width dbgrid 3 answers
i new delphi :). have made simple app able write , read sql server database. displaying query results in dbgrid.
currently, have 3 columns in db (id, name, surname). dbgrid displays them in waz dont like. can see id (its width accurate) , name, stretched way right, have use horizontal scrollbar see surname, extremely wide.
how can tell dbgrid adjust width of columns widest row?
my app looks this:
implementation {$r *.dfm} procedure tform1.button1click(sender: tobject); begin adoquery1.sql.text := 'insert [dbo].[client] ([meno],[priezvisko]) ' + 'values(:meno, :priezvisko)'; adoquery1.parameters.parambyname('meno').value := edit1.text; adoquery1.parameters.parambyname('priezvisko').value := edit2.text; adoquery1.execsql; end; procedure tform1.button2click(sender: tobject); begin adoquery2.sql.text := 'select * [dbo].[client] meno = :meno'; adoquery2.active := true; adoquery2.parameters.parambyname('meno').value := edit1.text; adoquery2.execsql; end; end.
i have found tutorial according this, have t double click on chosen coumn adjust width, , had problems line
columnwidthhelper.maxwidth := max(columnwidthhelper.maxwidth, dbgrid1.canvas.textwidth(column.field.displaytext)) ;
it not recognizing max function
any appreciated :)
the max
function in math
unit. add uses
clause.
Comments
Post a Comment