Home Forums WinForms controls Xceed Grid for WinForms Adding Check Box For Unbound Column for NON boolean Data type in Xceed Grid Version 2.2

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17169 |

    Hi,

    I have a requirement that maps to the following below table structure. The programming is done in VB.NET 1.1 using the 2.2 version of Xceed GRID. The table structure is as follows..

    ColName    ColValue

    Name         XYZ

    Age             23

    Married        <Should be Check Box>

    As it is clearly seen from above, the 2nd column i.e ColValue holds composite data type with objects in it. In General, it is off Object Data Type.

    What i want to achieve here is , how to add a object of type checkBox ? or in general any other object/control in a cell..? Please note that the Grid is unbound and the data is added as per the wish of developer and there is no constraint for the type of data that the column cell is going to HOLD.

    Appreciate any early help on this one.

    Thanks

    Mahesh

    Imported from legacy forums. Posted by Mahesh (had 3205 views)

    User (Old forums)
    Member
    Post count: 23064

    You don’t have to add a complex object to the grid.  Just adding a boolean would get the checkbox in place in the grid. 

    To set the column to boolean, add a column using the designer.  To set the type, hover the column name in the designer and right-click when you have the column icon selected (a black vertical bar followed by a grey vertical bar), select properties, select DataType, select System.Boolean.

    If you don’t want to set the column to a boolean type for every rows it contains, you will have to add each row manually (programmatically) and set a viewer and a manager for each of these rows.  You can check out our RichCellEditors sample application, for this matter. 

    In the end, your code should look like:

    dataRow = gridControl1.DataRows.AddNew();

    dataRow.Cells[ “ColName” ].Value = “Married”;

    dataRow.Cells[ “ColValue” ].HorizontalAlignment = HorizontalAlignment.Center;
    dataRow.Cells[ “ColValue” ].VerticalAlignment = VerticalAlignment.Center;
    dataRow.Cells[ “ColValue” ].CellEditorManager = new CheckBoxEditor();
    dataRow.Cells[ “ColValue” ].CellViewerManager = new CheckBoxViewer();
    dataRow.Cells[ “ColValue” ].Value = false; 

    Imported from legacy forums. Posted by Ghislain (had 1127 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Ghislain for your quick response.

    I am afraid that the solution you have given is not applicable in the Xceed grid that i am working with. Please note that the Xceed Grid i am working with is of version 2.2 and it is not having a CellViewManager or CellEditorManager class and neither CheckBoxEditor nor CheckBoxViewer class.

    The only class that is suppoted here is CellEditor/CellViewer with CustomEditor and ControlViewer class. I am attaching a piece of snippet that i am using which is not fully functional.

    The code that Creates a Check box in the cell is as follows where AttributeName and Attributevalues are the “Name” & “Values” w.r.t the table format that i have defined earlier in my Mail.

    ===============================================================================

    Dim

    newRow As Xceed.Grid.DataRow = grdDinDetail.DataRows.AddNew()

    Dim chkBox As New Xceed.Grid.Editors.GridCheckBox

    newRow.Cells(“colName”).Value = attributeName

    newRow.Cells(“colValue”).HorizontalAlignment = HorizontalAlignment.Center

    newRow.Cells(“colValue”).VerticalAlignment = VerticalAlignment.Center

    newRow.Cells(“colValue”).CellViewer = chkBox

    newRow.Cells(“colValue”).CellEditor = chkBox

    newRow.Cells(“colValue”).Value = attributeValue

    newRow.EndEdit()

    ===============================================================================

    The code to Create a Normal Row Entry is as follows

     Dim

    newRow As Xceed.Grid.DataRow = grdDinDetail.DataRows.AddNew()

    newRow.Cells(“colName”).Value = attributeName

    newRow.Cells(“colValue”).Value = attributeValue  ‘The attaribute value can be of any data type like string,integer

    newRow.EndEdit()

    ================================================================================

    I call the above piece of code in a sequence to

    1. Create a Normal row whose value can be of any data type such as string, integer etc in the “colValue”

    2. Create a CheckedBox row whose value can be a boolean in the “colValue”

    Now the Block or bottle Neck is, which ever the code i call first, the “colValue” is holding that type of data i.e if call “1” first and then “2” then column “colValue” can hold only string/Integer or else if i call “2” first and then “1” the “colValue” can hold boolean datatype only and no other type. Please note that the data type of  “colValue” is of type Object. This is done so that the colValue can hold any data type value.

     Buttom line is i need to achieve the table strcuture that i have specified in the first mail which can hold any kind of data along with any type of control in it. In my case the control it is check box. So i need a workable piece of code for version 2.2 to have  both control and datatype variants. For your Ref i am specifying the Table structure

    ColName                       ColValue

    Andre                           20987

    Domain                         Petro Expert

    Married                         <%CheckBox%>

    Age                               23

     

    I just need to acheive the above. Please advice

     

    Thanks

    Mahesh

    Imported from legacy forums. Posted by Mahesh (had 2759 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.