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
703
How do i add a custom control to ultrawin grid
posted
I just want to know is there any property or method to add a custom control to wingrid. I am using pretty old version of wingrid , its 2006 Vol 3 for clr 2.0. Actually i have a custom combo control that has colors as the contents. And i want it in inside my grid. Earlier i tried that column style as color but i was not getting the colors name as desired. while opting sometimes i was getting color as Color[Magenta], in case of known color or for custom selected colors Color[A=255,R=162,G=118,B=109]. While applying this to my grid cell text color i was getting parser error. So here are few questions 1. If i use Style - Color of the column then , what will be the common method to apply color from both text. As i am storing the selected color to db and on grid initialize layout event i am applying color to a particular cells forecolor. 2. If i use custom control, how to i use it as a template column , as we use in ASP.Net... 3. Or if i use Style-color, then how do i save the name of the color as string. On grid load it display Color[Magenta] and Color[A=255,R=162,G=118,B=109]. Any common thing that can be save and applied without any hassel, or is it possible to display only color in the grid cell, while using color dropdown Thanks
Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Amit,

    In the version you are using, the easiest thing to do would be to use a ValueList and attach it to the column. You could populate the list with items such that the DataValue of each item is a color and text of the item is whatever you want, like the color name. Here's some more info on how to do this:

    HOWTO:What is the best way to place a DropDown list in a grid cell?

    Amit Ranjan said:
    1. If i use Style - Color of the column then , what will be the common method to apply color from both text. As i am storing the selected color to db and on grid initialize layout event i am applying color to a particular cells forecolor.

    I'm not sure I understand your question. What's the DataType of this column?

    Amit Ranjan said:
    2. If i use custom control, how to i use it as a template column , as we use in ASP.Net...

    The version of the grid you are using doesn't have any support for embedding your own custom controls. It only supports embeddable editors, like UltraTextEditor, UltraComboEditor, UltraColorPicker, etc. You could derive from one of these controls or editors, but I think the ValueList approach would be a lot easier.

    In the latest version of the grid, we added a new editor which allows you to easily embed your own controls in the grid, so you might want to consider upgrading if that's what you need.

    Amit Ranjan said:
    3. Or if i use Style-color, then how do i save the name of the color as string. On grid load it display Color[Magenta] and Color[A=255,R=162,G=118,B=109]

    Doesn't really make much sense to save a color to a database as a string, you'd be better off using a numeric value. The ColorTranslator class in DotNet gives you a bunch of different ways to translate colors into values. To deal with this kind of thing in the grid, you would have to translate the value from the database into a Color object in the grid. There are a couple of ways to handle this. You could hide the actual bound column and use an unbound column to display to the users and then use grid events to copy and translate the values from one to the other. Or another option is to use a DataFilter on the column to do the translation for you.

     

Children
No Data