We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Header Image

I have hidden the header row in the databoundgrid control and made a the next row down a header row. how do i insert an image on the new column i''ve created?

7 Replies

AD Administrator Syncfusion Team November 4, 2004 11:27 PM UTC

Do you mean the new row that you added (as opposed to the new column)? If it is the row, then you can handle the PrepareViewStyleInfo event. In the handler, if e.COlindex and e.RowIndex point to the cell where you want the image, you can set e.Style.ImageList, e.Style.ImageIndex to specify the image you want to see. Additionally, you will have to set e.Style.CellType = "Static" so the image drawing code will be hit. (The default drawing for teh header celltype does not draw images.) There may be other properties you''ll want to set as well. There are other ways to do this if this will not serve your needs.


BH Bernard Herrok November 5, 2004 01:28 AM UTC

it''s just a standard row, made in into a column. .Model.Rows.HeaderCount = 1 >Do you mean the new row that you added (as opposed to the new column)? > >If it is the row, then you can handle the PrepareViewStyleInfo event. In the handler, if e.COlindex and e.RowIndex point to the cell where you want the image, you can set e.Style.ImageList, e.Style.ImageIndex to specify the image you want to see. Additionally, you will have to set e.Style.CellType = "Static" so the image drawing code will be hit. (The default drawing for teh header celltype does not draw images.) There may be other properties you''ll want to set as well. > >There are other ways to do this if this will not serve your needs.


AD Administrator Syncfusion Team November 5, 2004 06:49 AM UTC

I think the technique described above should work in this case. Here is a minimal sample. WindowsApplication9_235.zip


BH Bernard Herrok November 7, 2004 08:17 PM UTC

Ok, i got that to work. But how i change images at runtime? i have CellDoubleClick event, that changes the imageindex but it doesn''t update view. I thought that preparestyleview method was called every time the the grid refreshed. >I think the technique described above should work in this case. Here is a minimal sample. > > >WindowsApplication9_235.zip > >


BH Bernard Herrok November 7, 2004 09:06 PM UTC

Also, can i align the image to top on merged cells. i have dynamically merged cells and when image''s attached, it aligns in the center. thanks


AD Administrator Syncfusion Team November 7, 2004 10:59 PM UTC

What code are you using in your DounleClick handler? If you are trying to set grid[row, col].ImageIndex = ???, this will not work. In a GridDataBoundGrid, you cannot set cell specific properties (other than CellValue). Instead, you have to dynamically set the ImageIndex in PrepareViewStyleInfo. If you can post a sample project showing what you are trying to do, maybe I can suggest something.


BH Bernard Herrok November 8, 2004 12:30 AM UTC

your right, i can''t set the property outside the prepareviow. but if you use datagrid.refresh, it works. thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon