I am rendering the content of a database table in a TGrid, which works fine. Now I would like to show an image of a trash can on every row as a button to delete the row.
How can this be done?
How to render a TBitmap image in a cell of a TGrid?
1k Views Asked by Peter Holzer At
2
There are 2 best solutions below
0
Fajar Donny Bachtiar
On
try this code on event onDrawColumnCell
if stgMain.Cells[0, Row] = 'isImage' then begin
Bounds.Location := PointF(Bounds.Location.X, Bounds.Location.Y + ((Bounds.Height - Bounds.Width) / 2));
Bounds.Width := Bounds.Width;
Bounds.Height := Bounds.Width;
Canvas.Fill.Kind := TBrushKind.Bitmap;
Canvas.Fill.Bitmap.WrapMode := TWrapMode.TileStretch;
Canvas.FillRect(Bounds, 0, 0, AllCorners, 1);
Canvas.Fill.Bitmap.Bitmap := FMain.img.Bitmap(Bounds.Size, 2);
end;
Related Questions in DELPHI
- How to not load all database records in my TListbox in Firemonkey Delphi XE8
- How to catch WM_DEVICECHANGE in a control other than TForm?
- show information with Rolling / moving messages delphi xe7
- What is the different between "Console target" and "GUI target" in DCC32 option?
- How to add new online ressources to RAD Studio help system
- C# and Delphi code have different behaviour when importing unmanaged dll
- Loop through records on a cxgrid and update a field/column
- Delphi 7 - Save to a Specific .INI Files Name
- TImagelist for large images
- how to modify a function so it returns an array of strings
- Checking for internet connection in runtime
- How can I make the main form align correctly after my control height is autosized and then I maximize the form?
- fetch data from web service to dataset in Delphi
- Load candlestick data from file
- Infinite loop in parsing a string using pointer math
Related Questions in FIREMONKEY
- How to not load all database records in my TListbox in Firemonkey Delphi XE8
- how to modify a function so it returns an array of strings
- TabControl Navigation Buttons / Determine if Tab is Visible
- Nested forms with Showmodal in Win32/OSX
- How to Save files on external SD with Delphi XE8
- Firemonkey PNG to bitmap
- Firemonkey style designer make TRectangle fill parent
- Need help to find FireMonkey equivalent of the VCL TpaintBox.Canvas.Handle in the context of building graph
- Delphi - Copy an object
- How to handle TListBox scrolled all the way down to last TListBoxItem in Delphi XE8?
- Delphi fmx how to click through image and form?
- How i can set rgb color?
- Setting Firemonkey control font programmatically in C++
- Firemonkey how to implement app drawer-style tab control
- Accessing C-Objective code from within delphi?
Related Questions in TIMAGE
- Load images from the web to a TImage component
- MultiResolution in Firemonkey Mobile Application
- What is the simplest way to add an AlphaBlendValue property to Delphi's TImage
- Why doesn't this D2006 code to fade a PNG Image work?
- Can't get Gestures working on TImage Object in Delphi XE5
- Revert to design-time TImage picture
- Strange Delphi Android image assign / image garbled issue
- How can I get the width and length of a Picture in a Timage Component in Delphi Firemonkey
- Problem with painting with TImage. I have drawn on the TImage but it is not being painted
- Loading images into TImage, via array
- How to zoom images loaded in TImage control in Delphi XE2 Trial?
- How to render a TBitmap image in a cell of a TGrid?
- How to draw on the entire area of a resized TImage in Delphi?
- Can I retrieve Filename for TPicture directly?
- Scale an image nicely in Delphi?
Related Questions in TGRID
- Delphi Firemonkey TGrid how to update
- Firemonkey: Styling the tGrid or alternative Grid/List components (Virtual)
- How to render a TBitmap image in a cell of a TGrid?
- Slow performance of TGrid everytime it is created at runtime through dynamic (increasing data) TFDMemTable definition provided REST API data
- TTeeGrid is not displaying the data at runtime using data from REST
- How to display a TImage as a background of a TGrid on Firemonkey?
- Setting a Firemonkey control OnMouseMove method
- Highlighting TGrid row in code
- How to open a html file in a Grid, StringGrid or a DBGrid in Lazarus/Free Pascal?
- FireMonkey XE5 - Livebinding - TGrid - Cell text aligment
- How I can send the Changes of a TClientDataset back to a RTC Server?
- How to enter data into TGrid Cells in C++ Builder or Delphi
- Firemonkey XE5 TGrid scrolling issue using formatted cells
- Delphi XE4 Firemonkey Grid Control - Styling cells individually
- How to set 'selected' property of TGrid to -1
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are several ways to paint an image in a Grid. In cases, where the images will be loaded at runtime e.g. from a database, I prefer to use the
OnDrawColumnCellevent:This example expects an
ImageList1with several preloaded images. It draws all images into the column with the nameImageColumn1. To take your images from the database, replace the line with thebmpaccess.Update at 18-Apr-21:
If you simply want to show a trash icon or e.g. a status icon, you can put an image list on the form. Add a
TImageColumnorTGlyphColumn(e.g. as column number 2) and fill the image in this event into the cell:For a trash icon, you can write your delete action into the following event method: