Torna al Thread
public class MiaColonna : DataGridViewColumn
{
public MiaColonna() : base()
{
this.CellTemplate = new MiaCella();
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
base.CellTemplate = value;
}
}
public class MiaCella : DataGridViewCell
{
private Button b;
public MiaCella(): base()
{
b = new Button();
this.b.Text = "Bottone di prova";
b.Image = Image.FromFile("C:\prova.jpg");
}
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
Rectangle dimensioni = new Rectangle(cellBounds.Location.X, cellBounds.Location.Y, cellBounds.Size.Width, cellBounds.Size.Height);
b.Size = dimensioni.Size;
b.Location = dimensioni.Location;
this.DataGridView.Controls.Add(b);
}
}
}