Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
Button Appearance
posted

I am wanting to change my WinGrid cell button appearance depending on a value I have flagged (a boolean flag coming from the stored procedure).

 I have been successful in changing the appearance, a little, at least enough to know that it can be changed some.  I just want to make the button appearance change more drastic.

 In the Win Grid Initialize Row procedure I have the following code... 

If e.Row.Cells("Notes_Flag").Value = True Then

e.Row.Cells("Notes").ButtonAppearance.ForeColor = Color.Black

e.Row.Cells("Notes").ButtonAppearance.ThemedElementAlpha = Alpha.Transparent

e.Row.Cells("Notes").ButtonAppearance.Image = "~/Images/Notes.jpg"

Else

e.Row.Cells("Notes").ButtonAppearance.ForeColor = Color.Beige

End If

 

So now my button will change to the display text of black, and the button looks like a plain jane Windows button, if the flag = True.  If the flag = False, the button will change the text to the color of Beige (not visible) and the button looks like a XP button.  So I can tell quickly which records has the Notes_Flag checked and which ones do not.

Now I am wanting to spruce this up. 

 I would like to do the following...

The button's value is based on an ID, and this ID is needed to be passed to a stored procedure.  But I would like to either change the text of the button to read "Notes" (instead of displaying the ID value) OR insert an image (which ever is easier).  My code above to insert the image is ignored and I am not certain why.

Is this possible, or must the Button display the value of the cell it is connected to (unbound column)?

 Thank you,

T.J.

  • 469350
    Offline posted

    Hi T.J.,

        In order to answer your question, I need to know how you are creating the button in the cell. Are you just setting the Style on the column? If so, what Style are you using? Or are you using an editor to get the button?

        On a side note, this code is going to be very inefficient. By doing this, you will create a new Appearance object for every cell. So you are creating a large number of Appearance objects with the same properties. It would be better to use the InitializeLayout event of the grid to add an Appearance to the Appearances collection of the DisplayLayout and then assign that Appearance to the ButtonAppearance of the cell - thus re-using the same appearance. 

       

    TBernard said:

    e.Row.Cells("Notes").ButtonAppearance.ForeColor = Color.Black

    e.Row.Cells("Notes").ButtonAppearance.ThemedElementAlpha = Alpha.Transparent

    e.Row.Cells("Notes").ButtonAppearance.Image = "~/Images/Notes.jpg"