none
DataGridViewButtonColumn

    Question

  • Hi,

     

    I added an Unbound DataGridViewButtonColumn but to my DataGridView which was bound to a datasource.

     

    I used:

     

    buttoncolumn.text="HI";         // buttoncolumn is an object of DataGridViewButtonColumn

     

    But it is not displaying anything on running

     

    I want to dispaly the same data in all the buttons of the column. may be the same data as in the headercell.

     

    Please Help Its urgent....

     

    Regards

    Sangram

    Tuesday, July 31, 2007 3:42 PM

Answers

All replies

  •  

    you have to do the following

     

    from the datagridview smart tag,

    1. select the edit columns link,

    2. In the Edit Columns dialog, select the "button column"

    3. In the property grid for that column,

         set the text property to text you want to display say "click me"

         set the UseColumnTextForButtonValue to True

     

    Run your app, and you in the button in all the rows of the DGV will have the caption "Click Me"

     

     

    Tuesday, July 31, 2007 10:58 PM
  • Hi Naga,

    Thanks for reply.

     

    But I want it to be done at runtime... As I am adding the button column as last column in the DataGridView at run time

     

    Hope U can help me

     

    Wednesday, August 01, 2007 8:16 AM
  • try putting the statement

     

    column1.UseColumnTextForButtonValue = True;

     

     

    Wednesday, August 01, 2007 5:35 PM
  • Hi,please check following links

    http://msdn2.microsoft.com/en-us/library/zkatshfa(VS.80).aspx

    DataGridViewButtonColumn.CellTemplate Property (System.Windows.Forms ...

    Code Snippet

    Private Sub AddButtonColumn()
        Dim buttons As New DataGridViewButtonColumn()
        With buttons
            .HeaderText = "Sales"
            .Text = "Sales"
            .UseColumnTextForButtonValue = True
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
            .FlatStyle = FlatStyle.Standard
            .CellTemplate.Style.BackColor = Color.Honeydew
            .DisplayIndex = 0
        End With

        DataGridView1.Columns.Add(buttons)

    End Sub

     

     

    With Regards

    Thursday, August 02, 2007 3:45 AM