FlexGrid Set Values In Unbound Columns in Bound Control

Posted by: mwebster on 7 March 2019, 1:04 pm EST

    • Post Options:
    • Link

    Posted 7 March 2019, 1:04 pm EST

    I have a form with a FlexGrid control on it. It contains about 12 columns, 10 of which are bound to database fields. Two of the columns need to be set at runtime. No matter what I try to do, the FlexGrid will not show the values that I assign to the fields. I have tried using the SetData method and I have tried using code such as this:

    fgSalesDeals(x, 6) = DealAgeCondition

    No errors are returned, it simply does not display the data that I assigned to the field. The way this application needs to work makes it not possible to get the values into the grid in any way other than at runtime after the other columns have been populated from the database.

    Any suggestions?

  • Posted 8 March 2019, 8:12 am EST

    Hello,

    You can use the GetUnboundValue event to set the value of unbound columns. Please refer to the following lines of code and attached sample for implementing the same:

    
    
    //Adding two unbound Columns
    Column col = c1FlexGrid1.Cols.Add();
    col.Name = col.Caption = "Extra One";
    col = c1FlexGrid1.Cols.Add();
    col.Name = col.Caption = "Extra Two";
    //GetUnboundValue Event
    c1FlexGrid1.GetUnboundValue += C1FlexGrid1_GetUnboundValue;
    
    //Handle the event as per your requirement 
    private void C1FlexGrid1_GetUnboundValue(object sender, UnboundValueEventArgs e)
    {
           if (e.Col == 18)
           e.Value = Convert.ToInt32(c1FlexGrid1[e.Row, 4]) * 2;
           if(e.Col == 19)
            e.Value = Convert.ToInt32(c1FlexGrid1[e.Row, 4]) * 3;
    }
    
    

    Also, you can refer to the “UnboundColumns” product sample (Located at ~\Documents\ComponentOne Samples\WinForms\C1FlexGrid\CS) and following documentation link:

    https://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#C1.Win.C1FlexGrid.4~C1.Win.C1FlexGrid.C1FlexGridBase~GetUnboundValue_EV.html

    https://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#C1.Win.C1FlexGrid.4~C1.Win.C1FlexGrid.C1FlexGridBase~SetUnboundValue_EV.html

    Hope it helps

    Thanks.

    BoundUnbound.zip

  • Posted 8 March 2019, 9:35 am EST

    Thanks!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels