Articles in this section
Category / Section

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

3 mins read

Unbound column

You can add the unbound column using UnboundFields property from WinForms Grid Control 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 WinForms Grid Control

 

Samples:

C#: UnboundFields_CS

VB: UnboundFields_VB

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

Conclusion

I hope you enjoyed learning about how to add unbound field in WinForms GridGroupingControl with datasource as BindingList.

You can refer to our WinForms Grid Control’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Grid Control documentation to understand how to present and manipulate data. 

For current customers, you can check out our WinForms from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms Grid Control and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied