Add custom image to grid cell that is a RepositoryItemButtonEdit devexpress button

1k Views Asked by At

I am trying to add a custom image to a grid cell that is a RepositoryItemButtonEdit devexpress button.

When I execute the following code, I see nothing on the button.

            Dim image As System.Drawing.Image =  System.Drawing.Image.FromFile("C:\carl\addAccount.png")

            Dim buttonAdd As New RepositoryItemButtonEdit           
            buttonAdd.TextEditStyle = TextEditStyles.HideTextEditor
            buttonAdd.Buttons(0).Kind = ButtonPredefines.Ellipsis
            buttonAdd.Buttons(0).Image = image

            AddHandler buttonAdd.Click, AddressOf Me.Button_Click


            Dim unbColumn As GridColumn = gvView.Columns.AddField("Button")
            unbColumn.VisibleIndex = gvgvView.Columns.Count
            unbColumn.ColumnEdit = buttonAdd

            gvView.OptionsView.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways
1

There are 1 best solutions below

0
On BEST ANSWER

I guess you see ellipsis instead of your image. It's because you set the EditorButton.Kind property to ButtonPredefines.Ellipsis. You need it to be Glyph. see the possible values at ButtonPredefines Enumeration.

    Dim image As System.Drawing.Image =  System.Drawing.Image.FromFile("C:\carl\addAccount.png")

    Dim buttonAdd As New RepositoryItemButtonEdit           
    buttonAdd.TextEditStyle = TextEditStyles.HideTextEditor
    buttonAdd.Buttons(0).Kind = ButtonPredefines.Glyph
    buttonAdd.Buttons(0).Image = image

    AddHandler buttonAdd.Click, AddressOf Me.Button_Click


    Dim unbColumn As GridColumn = gvView.Columns.AddField("Button")
    unbColumn.VisibleIndex = gvgvView.Columns.Count
    unbColumn.ColumnEdit = buttonAdd

    gvView.OptionsView.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways