)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add unbound field in WinForms GridGroupingControl with datasource as BindingList?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: January 3, 2016 |
Last Revised Date: December 23, 2019

Unbound column

You can add the unbound column using UnboundFields property from GridTableDescriptor class and if you want to save the values in unbound column you can use the SaveValue and QueryValue event. You can get the saved values from SaveValue event. This value will be maintained in a Hashtable and then this value assigned to the unboundfield by using QueryValue event.

C#

//maintain the typed values in unbound column
Hashtable UnboundValues = new Hashtable();
this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("UnboundField");
this.gridGroupingControl1.TableDescriptor.QueryValue += new FieldValueEventHandler(TableDescriptor_QueryValue);
this.gridGroupingControl1.TableDescriptor.SaveValue += new FieldValueEventHandler(TableDescriptor_SaveValue);
void TableDescriptor_SaveValue(object sender, FieldValueEventArgs e)
{
    if (e.Field.Name == "UnboundField") 
    {
        UnboundValues[e.Record.Id] = e.Value;
    }
}
void TableDescriptor_QueryValue(object sender, FieldValueEventArgs e)
{
    if (e.Field.Name == "UnboundField")
    {
        e.Value = UnboundValues[e.Record.Id];
    }
}

 

VB

‘maintain the typed values in unbound column
Private UnboundValues As New Hashtable()
Me.gridGroupingControl1.TableDescriptor.UnboundFields.Add("UnboundField")
AddHandler gridGroupingControl1.TableDescriptor.QueryValue, AddressOf TableDescriptor_QueryValue
AddHandler gridGroupingControl1.TableDescriptor.SaveValue, AddressOf TableDescriptor_SaveValue
Private Sub TableDescriptor_SaveValue(ByVal sender As Object, ByVal e As FieldValueEventArgs)
    If e.Field.Name = "UnboundField" Then 
        UnboundValues(e.Record.Id) = e.Value
    End If
End Sub
Private Sub TableDescriptor_QueryValue(ByVal sender As Object, ByVal e As FieldValueEventArgs)
    If e.Field.Name = "UnboundField" Then
        e.Value = UnboundValues(e.Record.Id)
    End If
End Sub

 

Screenshot

Add unbound column in GridGroupingControl

 

Samples:

C#: UnboundFields_CS

VB: UnboundFields_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/managing-records-and-columns#unbound-columns

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon