hi all.

Is it possible to display an image in all buttons in a
datagridview(Windows Forms) button column? if yes,

can you help me how to do it?

Thank you,

Regards

Exelio

Are you speaking of the Header cells, or a data cell ?

I havn't tried it on tried it on the header, however I am pretty sure it can be done.
If you are speaking of data cells, you can use the
CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)

CellFormatting event to set the e.Value to an image.

//Jerry

Hi Exelio,

Yes I think it is possible. Just click on the gridview and click edit columns and then select the particular cell which you wanted to make a button and then in the Bound Column properties Window choose Column type under the design and select DataGridViewImageColumn for the columnType which you want the image to appear on. Then under the Appearance in the Bound Column properties you see the image text on the left side. just click on the right side infront of image text, then a window will pop up from there you can select your image. It should appear on all the buttons in the gridview.

Hope this helps

Cheers

Kisankoori.

On event dataGridViewMain_CellContentClick write following code

if (e.ColumnIndex == dataGridViewMain.Columns["ImageColumn"].Index)
{
lblShowCellData.Text = dataGridViewMain.Rows[e.RowIndex].Cells["CustomerName"].Value.ToString();
// Do some thing else....
}

<snip>

commented: necro-posting 5 year old posts to advertise -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.