My flygrid is bound to a strongly typed DataTable using the DataSource property. I'm trying to add an unbound column to display information related to one of the foreign keys in my datatable. When I add the unbound column, the flygrid displays \"System.Data.DataRowView\" in all the cells in the column. I've tried manually editing the values at runtime and setting the values programmatically, but I cannot change these values.
Can FlyGrid do mixed mode when bound to a DataTable? If so, what am I doing wrong? If not, what's the best/easiest way to display related data from multiple tables in my FlyGrid.
Thanks for your help!
Here's a visual basic sample of what I'm trying to do...
[VB.NET]
Imports NineRays.Windows.Forms
Imports NineRays.Windows.Forms.Data
Imports NineRays.Windows.Forms.Grids
Public Class Form1
Private dsMyDB As app1.MyDBDataSet 'MyDBDataSet was created using the Data Source Designer
Private fg As FlyGrid
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.dsMyDB = New MyDBDataSet
Me.fg = New FlyGrid
Me.fg.Dock = DockStyle.Fill
Me.fg.Rows.DataSource = Me.dsMyDB
Me.fg.Rows.DataMember = Me.dsMyDB.CompanyContacts.TableName
Me.Controls.Add(Me.fg)
prepareColumns(Me.fg)
prepareData(Me.dsMyDB)
addUnboundColumn(Me.fg)
End Sub
Private Sub prepareColumns(ByVal fg As FlyGrid)
Dim colCompany As New LookupListColumn
With colCompany
.Caption = \"Company\"
.FieldName = Me.dsMyDB.CompanyContacts.CompanyIDColumn.ColumnName
.FitMode = ColumnFitMode.SmartFit
.LookupSource = Me.dsMyDB.Companies
.LookupBoundField = Me.dsMyDB.Companies.CompanyIDColumn.ColumnName
.LookupDisplayField = Me.dsMyDB.Companies.CompanyNameColumn.ColumnName
End With
Dim colContact As New LookupListColumn
With colContact
.Caption = \"Contact\"
.FieldName = Me.dsMyDB.CompanyContacts.ContactIDColumn.ColumnName
.FitMode = ColumnFitMode.SmartFit
.LookupSource = Me.dsMyDB.Contacts
.LookupBoundField = Me.dsMyDB.Contacts.ContactIDColumn.ColumnName
.LookupDisplayField = Me.dsMyDB.Contacts.ContactNameColumn.ColumnName
End With
Dim cols() As Column = {colCompany, colContact}
fg.Columns.Items.AddRange(cols)
End Sub
Private Sub prepareData(ByVal ds As MyDBDataSet)
ds.Companies.Clear()
ds.CompanyContacts.Clear()
ds.Contacts.Clear()
'MyDBDataSetAdapters was created using the Data Source Designer
'The tables \"Companies\" and \"Contacts\" are lookup tables
'The table \"CompanyContacts\" is a junction table with foreign keys to Companies and Contacts
Dim taCompanies As New MyDBDataSetTableAdapters.CompaniesTableAdapter
taCompanies.Fill(ds.Companies)
Dim taCompanyContacts As New MyDBDataSetTableAdapters.CompanyContactsTableAdapter
taCompanyContacts.Fill(ds.CompanyContacts)
Dim taContacts As New MyDBDataSetTableAdapters.ContactsTableAdapter
taContacts.Fill(ds.Contacts)
End Sub
Private Sub addUnboundColumn(ByVal fg As FlyGrid)
'The contact's phone number is in the \"contacts\" table
Dim colPhone As New Column
With colPhone
.Caption = \"Phone\"
.FitMode = ColumnFitMode.SmartFit
End With
fg.Columns.Items.Add(colPhone)
End Sub
End Class