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 can I read the header of request to webserver
- Receiving Notifications for Individual Task Completion OmniThreadLibrary Parallel.ForEach
- Delphi - How to get result of function from QuickReport without viewing a report?
- Out of memory while adding documents to a Firebird BLOB field with Delphi
- How to MakeScreenshot fullpage on Delphi
- How to program a COM object with an IEnumerator, IEnumerable interface inside
- How to Dynamically Add Controls to Delphi Form
- How to write a string in Stringrid with DelimitedText in FMX Delphi 11
- TGrid/TStringGrid multi cell selection / multi editing in delphi firemonkey (12)
- How to localize "Today" in the Delphi TMonthCalendar?
- How can I call a SOAP webserver method in Vue.js?
- Efficiently Handling Large Number of API Calls with Delphi 10.4 and OmniThreadLibrary
- Delphi can not compile the unit create by its "XML Data Binding Wizard"
- Save Form Properties in File and then restore those Properties after reopening
- Is it possible to open a blob without saving it to file
Related Questions in FIREMONKEY
- How to MakeScreenshot fullpage on Delphi
- How to write a string in Stringrid with DelimitedText in FMX Delphi 11
- TGrid/TStringGrid multi cell selection / multi editing in delphi firemonkey (12)
- Tlabeledit component for FMX framework
- Fastest way to draw a wave distortion effect in Delphi FMX?
- Delphi FMX Android Printing with Sunmi V2 Device
- How to debug on Android device via WI-FI
- Default Text Property for Custom Button in Delphi
- How to capture Enter key (vkReturn) in Delphi FMX on Android?
- Getting list of devices plugged in in a pc (windows platform)
- Delphi FMX: How to write a custom shader filter?
- NetCom7 Chat Demo
- .dylib not Found Trying to Open the Program After Being Generated by PAServer
- Delphi - TakePhotoFromCameraAction - photo resolution
- How do I determine the "z-index" of a Firemonkey component that I have used SendToBack or BringToFront methods on?
Related Questions in TIMAGE
- Load image from URL into a TImage
- How to copy content of timage from form1 to form2?
- Copy text drawn on TImage to another TImage
- How to convert TImage and TImageControl coordinates to underlying bitmap coordinates?
- Problem with painting with TImage. I have drawn on the TImage but it is not being painted
- How can I get the width and length of a Picture in a Timage Component in Delphi Firemonkey
- StretchDraw to printer.canvas loses the transparency
- Assign a picture to a TImage and define the background color of transparent pixels
- Speed up image loading in TImage
- Delphi Game Timer program freezes up after 1.5 to 2 hours and sometimes gives an exception "Canvas does not allow"
- How do I make a TImage move (like a DVD logo)
- Showing an animated .ani cursor on a form in Delphi 7
- Try..Except ignored inside a thread
- Delphi Custom TImage Component - MouseEnter, MouseLeave in component
- How to duplicate TImage component with the image using RTTI
Related Questions in TGRID
- TGrid/TStringGrid multi cell selection / multi editing in delphi firemonkey (12)
- How to render a TBitmap image in a cell of a TGrid?
- How to open a html file in a Grid, StringGrid or a DBGrid in Lazarus/Free Pascal?
- Slow performance of TGrid everytime it is created at runtime through dynamic (increasing data) TFDMemTable definition provided REST API data
- TTeeGrid at runtime creation gets slower as the number of columns increases
- TTeeGrid is not displaying the data at runtime using data from REST
- TGrid not Working with iOS simulator — it just run briefly and gone after installation
- How to set text alignment for a specific column in firemonkey TGrid/TStringGrid?
- How to display a TImage as a background of a TGrid on Firemonkey?
- FMX.TGrid how to allow user to move columns without messing up the data
- How to get cell value from specific column/row in a FireMonkey TGrid
- Delphi Firemonkey Grid: Invisible Columns When Navigating
- fmx delphi berlin how to change font color in rows of Tgrid
- Delphi Firemonkey TGrid usage
- How to enter data into TGrid Cells in C++ Builder or Delphi
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 # Hahtags
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: