[RESOLVED] DataGrid - rendering cell
Hi all,
I am using Visual Studio C#, and I am new to C#
At the moment, I am getting myself familiarize with DataGrid. It seems like I can only put text in the cells of the DataGrid, I am wondering if I can render a image into the DataGrid cell.
I have a program that will list the files in a directory, and I want to display an image on a DataGrid cell according to the file types.
For example, if the file is a mp3 file, then I will put a MP3 icon into the cell; if the file is a .wav file, then I will put a windows media player icon into the cell; if the file is a text file, I will put a text file icon into the cell.
Could anyone tell me if this is possible to implement? and perhaps give me a hint on how this should be implemented.
Any help is appreciated,
Thank you,
kab
Re: DataGrid - rendering cell
I am not sure which version of Visual Studio you are using. Assuming Visual Studio 2005 Windows project, there is DataGridViewImageColumn in DataGridView control. You can bind image data to the column, or set image data to cell value. If you are doing 2005 Web project, just set the column to template field and then play around.
Hope it helps.
Re: DataGrid - rendering cell
Quote:
Originally Posted by
jasonli
I am not sure which version of Visual Studio you are using. Assuming Visual Studio 2005 Windows project, there is DataGridViewImageColumn in DataGridView control. You can bind image data to the column, or set image data to cell value. If you are doing 2005 Web project, just set the column to template field and then play around.
Hope it helps.
Hi Jasonli,
I found out that I need to create my own DataGridTableStyle and DataGridColumnStyle, and bind the customed styles to my datagrid. The process is still a bit blur to me at the moment. I have found a code example online and reading through it right now.
If you are interested, I can post it up for you to look at.
Thank you for your help,
kab