HOW TO: Change datagridview LinkColumn Text when clicked

Unknownymous

I'm having a problem in my DataGridViewLinkColumn. When specific columnIndex clicked, I want to change the link column text. (please see example below) enter image description here

In example above, I want to change the text(the highlighted one) that is clicked to SAVE.
NOTE: the changing must be done only in specific row and column index

I used datagridViewColumn and here's my code: (link column displays when bind in datatable then display to datagrid.)

        Dim da As New SqlDataAdapter("SELECT DateReq AS [Date Requested],NoHrs AS [# OT Hrs.],status,approved_by FROM tableName" _
            & "WHERE requested_by='" & lbluserid.Text & "'" _
            & " ORDER BY date_request ASC", Constr)
        Dim dt As New DataTable

        ds.Clear()
        da.Fill(dt)


        dg.DataSource = dt

        dg.Columns.Add(lnkEdit)
        lnkEdit.HeaderText = ""
        lnkEdit.Name = "edit"
        lnkEdit.Text = "Edit"
        lnkEdit.UseColumnTextForLinkValue = True
        dg.Columns(4).Width = 45
        dg.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter

        dg.Columns.Add(lnkCancel)
        lnkCancel.HeaderText = ""
        lnkCancel.Name = "cancel"
        lnkCancel.Text = "Cancel"
        lnkCancel.UseColumnTextForLinkValue = True
        dg.Columns(5).Width = 45
        dg.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
sloth

Just handle the CellContentClick event, get the right cell and set it's value:

' If your DataGridView is named dataGridView1: '
Private Sub dataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dataGridView1.CellContentClick
    dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "Saved"
End Sub

Note that your problem is that a DataGridViewLinkCell either displays it's Value (when UseColumnTextForLinkValue == false), or it displays the Text of it's DataGridViewLinkColumn (when UseColumnTextForLinkValue == true).

So if you want to change the text of the link at runtime you'll have to set UseColumnTextForLinkValue = false, and fill the cells beforehand with the text Edit, e.g. something like:

For Each row in dg.Rows
    row(your_link_column).Value = "Edit"
Next

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to change the height of a single cell when clicked?

From Dev

How to change title color of UIButton when clicked?

From Dev

How to change button image when clicked in xaml

From Dev

Change DIV text when a button is clicked using JS/JQ

From Dev

Change button text when clicked (more/less)

From Dev

Change text when link clicked with jQuery

From Dev

How to change the image of an ImageView when clicked?

From Dev

How do I change the text of a button when it is clicked? - Swift

From Dev

Change the text of an anchor tag when clicked in ng-click method

From Dev

Trying to change individual letters of text when clicked on using JavaScript

From Dev

How to display text when a glyphicon is clicked

From Dev

How to change text in button when clicked?

From Dev

Change text when different images are clicked in React.js

From Dev

How to change button content when clicked in Xaml?

From Dev

How to change font of a button when clicked?

From Dev

how to change QLabel to QCombobox when clicked

From Dev

when DataGridView ButtonColumn Clicked

From Dev

how to change to next page when clicked on button

From Dev

How to change the image and text color of clicked position in listview row in android

From Dev

In ADF Mobile, How to change the button text when the button is clicked?

From Dev

How to change the text value of the button everytime it is being clicked?

From Dev

How to change text of the top left cell of a datagridview?

From Dev

Change the text of an anchor tag when clicked in ng-click method

From Dev

How to change an image in a ListView, when the image is clicked?

From Dev

How to change text in button when clicked?

From Dev

Change <i> when clicked on

From Dev

How to start SearchActivity when clicked on edit text

From Dev

Change text on a button type when clicked

From Dev

Change text-color when double clicked

Related Related

  1. 1

    how to change the height of a single cell when clicked?

  2. 2

    How to change title color of UIButton when clicked?

  3. 3

    How to change button image when clicked in xaml

  4. 4

    Change DIV text when a button is clicked using JS/JQ

  5. 5

    Change button text when clicked (more/less)

  6. 6

    Change text when link clicked with jQuery

  7. 7

    How to change the image of an ImageView when clicked?

  8. 8

    How do I change the text of a button when it is clicked? - Swift

  9. 9

    Change the text of an anchor tag when clicked in ng-click method

  10. 10

    Trying to change individual letters of text when clicked on using JavaScript

  11. 11

    How to display text when a glyphicon is clicked

  12. 12

    How to change text in button when clicked?

  13. 13

    Change text when different images are clicked in React.js

  14. 14

    How to change button content when clicked in Xaml?

  15. 15

    How to change font of a button when clicked?

  16. 16

    how to change QLabel to QCombobox when clicked

  17. 17

    when DataGridView ButtonColumn Clicked

  18. 18

    how to change to next page when clicked on button

  19. 19

    How to change the image and text color of clicked position in listview row in android

  20. 20

    In ADF Mobile, How to change the button text when the button is clicked?

  21. 21

    How to change the text value of the button everytime it is being clicked?

  22. 22

    How to change text of the top left cell of a datagridview?

  23. 23

    Change the text of an anchor tag when clicked in ng-click method

  24. 24

    How to change an image in a ListView, when the image is clicked?

  25. 25

    How to change text in button when clicked?

  26. 26

    Change <i> when clicked on

  27. 27

    How to start SearchActivity when clicked on edit text

  28. 28

    Change text on a button type when clicked

  29. 29

    Change text-color when double clicked

HotTag

Archive