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
435
Adding a picture to rows in grid from a imagelist
posted

HI,

I'm stuck, I have a imagelist containing all world country flags and I have a grid that shows all countries with their 2 charactter code. What I want to do is to add a column to show the corresponding country flag in the grid.

I'm doing this in VB.Net can any-one help me with a code sample how to do this. Once this is done I want to use the same technique in other grids that show users show the flag of the country they are in.

Beste Regards

 

Ronny

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Ronny,

    Does the image have to be in a separate column? Or would it be okay if it was in the same column with the text?

    If the latter is okay, then I recommend using a ValueList for this column. What you would do is create a ValueList with a list of countries in it. Each item in the ValueList can have a DataValue (the 2-character country code), a DisplayText (the full name of the country to display to the user), and you can also assign an Image to the Appearance if each item for the flag. If you attached such a ValueList to the grid column, then it will handle showing the images and the display text in the grid and you don't have to do anything else.

    If you prefer to show the flag in a separate column, then the thing to do is using the InitializeLayout event of the grid to add an unbound column to the band and set the DataType on that column to Bitmap. Then you would use the InitializeRow event to examine the value in the county column and set the Value of the unbound bitmap column to an image.

Children
No Data