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;
------------------------------------------------------------------
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;
------------------------------------------------------------------