DataGridTextBoxColumn Paint event never executed

G

Guest

There's something very strange in my windows application. I created a derived
class from DataGridTextBoxColumn to show pictures on a column of the datagrid
control.
Everything seems fine except that the paint event of the derived class is
never executed (no matter where the breakpoint is put).
I pasted here both the derived class and the code where I bind the instance
of the derived class to the 2nd column of the datagrid.
If anyone sees what's wrong, please drop me a line.

Thanks in advance.

Mirco

------------------------------------------------------------------
-derived-class--------------------------------------------------
------------------------------------------------------------------
public class DataGridImageColumn : DataGridTextBoxColumn
{
public DataGridImageColumn() : base()
{}

protected override void Paint(Graphics g, Rectangle bounds,
CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool
alignToRight)
{
// get the cell content
object o = this.GetColumnValueAtRow(source, rowNum);

// do something with "o" ...
}
}
------------------------------------------------------------------

------------------------------------------------------------------
-binding---------------------------------------------------------
------------------------------------------------------------------
DataGridImageColumn dgColumn2 = new DataGridImageColumn();
dgColumn2.MappingName = "Preview";
dgColumn2.HeaderText = "Preview";
dgColumn2.Width = 50;
dgTableStyle.GridColumnStyles.Add(dgColumn2);

// add the table style to the datagrid
this.ItemsDataGrid.TableStyles.Add(dgTableStyle);

// set the datasource
this.ItemsDataGrid.DataSource = m_DataTable;
------------------------------------------------------------------
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Mark,

As far as I remember Paint has several overloads, you should override all of
them because it is possible that different overloads get called under
different circumstances.
 
G

Guest

Hi Dmitriy,

thanks for your reply, unfortunately I already tryed that setting a
breakpoint on each overloads of the Paint method. Noone is crossed.

Mirco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top