GridGroupingControl - Custom PictureBox

Hi,

I am using a GridGroupingControl to display images within the grid. I use the PictureBoxCellModel and PixtureBoxCellRenderer as examples for how to do this. As I am binding to an IList, I cannot set the cell style directly - instead I look to set it having added the columns, like so:

GridStyleInfo style = grid.TableModel.ColStyles["MyColumn"];

style.CellType = "PictureBox";

I also use "PictureBox" when I add the Cell Model:

grid.TableModel.CellModels.Add("PictureBox", new PictureBoxCellModel(gridControl1.Model));

However, this does not display images! I noticed that after setting the relevant ColStyle's 'CellType' to "PictureBox", the 'CellType' is still set to "TextBox"!!! Hence, the 'OnDraw' and 'OnLayout' methods never execute in the PictureBoxCellRenderer!

A colleague told me of a way round this - I had to set the style's CellType in the 'QueryCellStyleInfo' event instead. I did this and it now works. But it makes no sense why! I should be able to set the style's CellType at the same point of adding the CellModel. I see no logical reason why I have to grab the 'QueryCellStyleInfo' event and then have to set the CellType at this point. I have wasted way to long trying to solve this unobvious problem.

Can Syncfusion please let me know why I have to use the 'QueryCellStyleInfo' event, or, could you provide a better way of setting the CellType on a style?

Regards,
Russell

2 Replies

RC Russell Coombes September 18, 2007 05:03 PM UTC

Please ignore or delete this forum post - I have recreated it in the Grid Forum.

Thanks,
Russell

>Hi,

I am using a GridGroupingControl to display images within the grid. I use the PictureBoxCellModel and PixtureBoxCellRenderer as examples for how to do this. As I am binding to an IList, I cannot set the cell style directly - instead I look to set it having added the columns, like so:

GridStyleInfo style = grid.TableModel.ColStyles["MyColumn"];

style.CellType = "PictureBox";

I also use "PictureBox" when I add the Cell Model:

grid.TableModel.CellModels.Add("PictureBox", new PictureBoxCellModel(gridControl1.Model));

However, this does not display images! I noticed that after setting the relevant ColStyle's 'CellType' to "PictureBox", the 'CellType' is still set to "TextBox"!!! Hence, the 'OnDraw' and 'OnLayout' methods never execute in the PictureBoxCellRenderer!

A colleague told me of a way round this - I had to set the style's CellType in the 'QueryCellStyleInfo' event instead. I did this and it now works. But it makes no sense why! I should be able to set the style's CellType at the same point of adding the CellModel. I see no logical reason why I have to grab the 'QueryCellStyleInfo' event and then have to set the CellType at this point. I have wasted way to long trying to solve this unobvious problem.

Can Syncfusion please let me know why I have to use the 'QueryCellStyleInfo' event, or, could you provide a better way of setting the CellType on a style?

Regards,
Russell



RB Ragamathulla B Syncfusion Team September 7, 2012 06:32 AM UTC

Hi Russell,

 

Thank you for your interest in syncfusion products.

 

Please make use of the Grid.TableModel instead of gridcontrol1.Model which is resolve your reported issue.

 

Way 1:

grid.TableModel.CellModels.Add("PictureBox", new PictureBoxCellModel(gridControl1.Model));

 

Way 2:

 

Bitmap bm = Bitmap.FromFile(@"Animated.gif") as Bitmap;

            this.pictureBox1.Image = bm;

 

            this.grid.TableModel.ColStyles[2].CellType = "Control";

            this.grid.TableModel.ColStyles[2].Control = this.pictureBox1;

 

Hope this will be helpful for your reference.

 

http://www.syncfusion.com/support/forums/grid-windows/103636/Displaying-a-gif-image-inside-a-cell-is-not-work

 

Regards,

Ragamathullah B.


Loader.
Up arrow icon