Command Column Click Event

7 posts, 1 answers
  1. KUMARAN
    KUMARAN avatar
    28 posts
    Member since:
    May 2014

    Posted 25 Apr 2015 Link to this post

    I want get the some column detail by clicking the command button.

    Ex: If a had price 10 as default and when i click command button the price will be updated as 12.

    How can do this by using programmatically.

     Thanks in advance.

    Note: VB Coding

  2. KUMARAN
    KUMARAN avatar
    28 posts
    Member since:
    May 2014

    Posted 25 Apr 2015 Link to this post

    I will be glad if you send a sample attachment in vb.
      
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 25 Apr 2015 Link to this post

    This will do what I *think* you are asking for, just a sample but should point the way:

    Private Sub Form1_Load( sender As Object,  e As EventArgs) Handles MyBase.Load
        
           'create a command column (button)
           Dim commandColumn As New GridViewCommandColumn()
           'name it so we cah check for it later
           commandColumn.Name = "change"
           commandColumn.UseDefaultText = False
           commandColumn.HeaderText = "Command"
           'add the button
           RadGridView1.MasterTemplate.Columns.Add(commandColumn)
           'add a column to hold price info
           Dim priceColumn As New GridViewTextBoxColumn()
           priceColumn.Name = "price"
           priceColumn.HeaderText = "Price"
           RadGridView1.MasterTemplate.Columns.Add(priceColumn)
           'Adds three rows of data to the grid
           radgridview1.rows.add("Add","10")
           radgridview1.rows.add("Add","13")
           radgridview1.rows.add("Add","15")
     
     
       End Sub

     then in the events of the grid box choose the CellClick event and put something like this:

    Private Sub RadGridView1_CellClick( sender As Object,  e As GridViewCellEventArgs) Handles RadGridView1.CellClick
            'everytime a cell is clicked this will run, check to see if they clicked the column named change
            if e.Column.name = "change"
                'if so then take the current row and replace the value with whatever is typed in the textbox1
                RadGridView1.mastertemplate.currentrow.cells("price").value = textbox1.text
     
            End If
    End Sub

     

    Let me know if you need clarification.

    Joe

     

  5. Answer
    Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 25 Apr 2015 in reply to Joe Link to this post

    Sorry...I formatted the code as c#...here is it formatted correctly:

     

      Private Sub Form1_Load( sender As Object,  e As EventArgs) Handles MyBase.Load
         
            'create a command column (button)
            Dim commandColumn As New GridViewCommandColumn()
            'name it so we cah check for it later
            commandColumn.Name = "change"
            commandColumn.UseDefaultText = False
            commandColumn.HeaderText = "Command"
            'add the button
            RadGridView1.MasterTemplate.Columns.Add(commandColumn)
            'add a column to hold price info
            Dim priceColumn As New GridViewTextBoxColumn()
            priceColumn.Name = "price"
            priceColumn.HeaderText = "Price"
            RadGridView1.MasterTemplate.Columns.Add(priceColumn)
            'Adds three rows of data to the grid
            radgridview1.rows.add("Add","10")
            radgridview1.rows.add("Add","13")
            radgridview1.rows.add("Add","15")
     
     
        End Sub
     
     
     
    Private Sub RadGridView1_CellClick( sender As Object,  e As GridViewCellEventArgs) Handles RadGridView1.CellClick
            'everytime a cell is clicked this will run, check to see if they clicked the column named change
            if e.Column.name = "change"
                'if so then take the current row and replace the value with whatever is typed in the textbox1
                RadGridView1.mastertemplate.currentrow.cells("price").value = textbox1.text
     
            End If
    End Sub

     

  6. KUMARAN
    KUMARAN avatar
    28 posts
    Member since:
    May 2014

    Posted 26 Apr 2015 in reply to Joe Link to this post

    Thanks for the Reply.How to Edit and Delete Forum threads, in case if i made a mistake in my Questions.
  7. Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 26 Apr 2015 in reply to KUMARAN Link to this post

    Hello;

    I don't think you can on here (like on Stackoverflow?)  Also, I would have uploaded the project but this does not allow upload of anything except pictures.

    Let me know if this works out for you.

    Good luck and happy coding!

    Joe

  8. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 29 Apr 2015 Link to this post

    Hello guys,

    @Joe, thank you for sharing your solution with our community. Your Telerik points are updated accordingly. 

    @Kumaran, users are not allowed to modify their posts. More detailed information on using our forum you can find here: Important Information on Using the Telerik Forums

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready