Forum > Databases

[SOLVED] DBGrid icon

(1/2) > >>

Pe3s:
Hello, how can I put an icon in the DBGrid component in any column?

dsiders:

--- Quote from: Pe3s on June 05, 2023, 08:51:20 pm ---Hello, how can I put an icon in the DBGrid component in any column?

--- End quote ---

You can use the OnDrawColumnCell event handler (TDrawColumnCellEvent) if it's not a fixed cell.

Pe3s:
Thank you :)

Pe3s:
Hello, how can I improve the code so that it does not draw bold text in columns?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;  DataCol: Integer; Column: TColumn; State: TGridDrawState);begin   if Column.FieldName = 'Category' then begin      ImageList1.Draw(DBGrid1.Canvas, Rect.Left, Rect.Top, 0)  end;    DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);end; 

wp:

--- Quote from: Pe3s on June 10, 2023, 11:52:44 am ---Hello, how can I improve the code so that it does not draw bold text in columns?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;  DataCol: Integer; Column: TColumn; State: TGridDrawState);begin   if Column.FieldName = 'Category' then begin      ImageList1.Draw(DBGrid1.Canvas, Rect.Left, Rect.Top, 0)  end;    DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);end; 
--- End quote ---
"does not draw bold text in columns" - if this means: the text in the columns should not be bold, the answer is: Don't add the fsBold style to the DBGrid1.Canvas.Font.Style or DBGrid1.Font.Style - you must be doing this somewhere because this is not default behaviour, but, of course, I don't know where you do this since you do not show this code.

If it means: there should not be ANY text in the columns, the answer is: Remove the call to DBGrid1.DefaultDrawColumnCell from above code.

Navigation

[0] Message Index

[#] Next page

Go to full version