0

My question is how to add the word "delete" in a cell of the 5th Column of a DataGridView ?

I am implementing a function of delete, to delete a row when a user clicks anywhere in the 5th column in a DataGridView.

I have no problem handling a CellClick event. But the problem for me is how to add the word "Delete" to each cell of the 5th Column?

David Hall
  • 32,624
  • 10
  • 90
  • 127
Kam2012
  • 257
  • 2
  • 4
  • 8
  • Why not have buttons in the column? Check is [this](http://stackoverflow.com/questions/1168976/wpf-datagrid-button-in-a-column-getting-the-row-from-which-it-came-on-the-cli) is any help – Johan Larsson Dec 29 '12 at 23:15

1 Answers1

0

In code you can use the following statement, which assumes Column(5) is a Button:

CType(YourDataGridView.Columns(5), DataGridViewButtonColumn).UseColumnTextForButtonValue = True

You can also set this property using the Columns property (Appearance section) of the DataGridView control.

ron tornambe
  • 10,452
  • 7
  • 33
  • 60
  • under the appearance, i just can see the "DefaultCellStyle" and "Header Text" and "Tooltip Text" and "Visible", and the "Header Text" is not i am looking for. – Kam2012 Dec 29 '12 at 23:44
  • You must use a DaataGFridViewButton control for this top work. You can then also replace the "Delete" text with an image. – ron tornambe Dec 30 '12 at 00:45
  • Sorry, where you get the DaataGFridViewButton control from ? – Kam2012 Dec 30 '12 at 00:48
  • In the Design section, click on "ControlType" - a combo-box with available controls is listed. – ron tornambe Dec 30 '12 at 01:02
  • I know you are new to S.O., but if your questions is correctly answer, it is customary to accept (or up-vote) the answer. – ron tornambe Dec 30 '12 at 02:36