Results 1 to 9 of 9

Thread: Data Grid View Button handling - Change button.text

  1. #1
    Tinshooter is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2011
    Posts
    6
    Reputation
    0

    Data Grid View Button handling - Change button.text

    Ok VB Gurus, I have a data grid view with 2 buttons, Start and End. Upon clicking the button, I want to change the button.text with a time stamp. I know how to create a time stamp, but I can't figure out how to change the text from "Start" to say for example "9:21 PM" Can anyone help? I hope I was clear enough.

    So far I have:
    If e.ColumnIndex <> 1 Then
    The code to change the button.text, I am assuming would go here.
    Dim tm As System.DateTime
    tm = Now

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,336
    Reputation
    1543
    How do you normally change what is contained in a cell in a DataGridView?

  3. #3
    Tinshooter is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2011
    Posts
    6
    Reputation
    0
    Well, as of right now I have it set through the datagriview properties. But I want to manually change it with code after the buttonclick, It is very easy outside of a datagridview; I just can't figure out the syntax to do it inside of it.

  4. #4
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,336
    Reputation
    1543

  5. #5
    Tinshooter is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2011
    Posts
    6
    Reputation
    0
    How would I normally do it? I suppose I would type right in it, do you understand why what isn't possible in this case?

  6. #6
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,336
    Reputation
    1543
    I'm not talking about you the user. I'm talking about you the programmer. How would you change the contents of a cell in a DataGridView in code?

  7. #7
    Tinshooter is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2011
    Posts
    6
    Reputation
    0
    That is exactly what I am trying to figure out, I can not seem to find any kind of syntax examples to do this.

    I clearly understand how to do it with e textbox - txtTextbox.Text = ... But I am struggling with this because of the rows and columns.

  8. #8
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,188
    Reputation
    2368

  9. #9
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,336
    Reputation
    1543
    I'm not sure you're actually trying to answer the question I asked. To change the contents of any cell you set its Value property. That's the question I asked, not how to get a reference to the cell in the first place. JohnH has now answered that question too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking