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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

column binding question

Thread ID:





15123 Jun 11,2004 10:40 AM UTC Jun 11,2004 11:22 AM UTC WinForms 2
Tags: GridControl
Lee Perkins
Asked On June 11, 2004 10:40 AM UTC

I''m binding an custom Incomes collection to a GDBG. Incomes holds Income objects. My Income Class has public properties called EmployerName (String), and IncType (an IncomeType object). The IncomeType class has a property for IncomeTypeName (String). Can I bind the columns in the grid so they show IncomeObject.EmployerName and IncomeObject.IncomeType.IncomeTypeName? Here''s some (simplified) code showing how I''m trying it. The result is the EmployerName shows, but the IncType.IncomeTypeName doesn''t. I get the IncType column, but it''s just blank. Dim gbc As New GridBoundColumn gbc = New GridBoundColumn gbc.MappingName = "IncType.IncomeTypeName" gbc.HeaderText = "Source" dtgEmployerInfo.GridBoundColumns.Add(gbc) gbc = New GridBoundColumn gbc.MappingName = "EmployterName" gbc.HeaderText = "Employer" dtgEmployerInfo.GridBoundColumns.Add(gbc) dtgEmployterInfo.DataSource = m_Incomes ----- Lee Perkins

Administrator [Syncfusion]
Replied On June 11, 2004 11:10 AM UTC

We currently do not support accessing nested properties in this manner. You could use an event to swap out what is displayed. You could use either PrePareViewStyleInfo or model.QueryCellFormattedText to handle this. You would just set the MappingName to gbc.MappingName = "IncType". Then in PrepareViewStyleInfo if e.RowIndex > 0 and e.ColIndex points to this column, you can retrieve the IncType object from e.Style.CellValue, and then set e.Style.Text equal to the IncType.IncomeTypeName value.

Lee Perkins
Replied On June 11, 2004 11:22 AM UTC

Thanks for the suggestion. The solution I just finished testing and implementing was to override ToString() in the IncomeType class to return the IncomeType.IncomeTypeName, then just bind the "IncType" property to the column. Worked like a champ! :) ----- Lee Perkins


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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