Probably parent column in relation has no unique values,
please set parentColumn.Unique = true.
Below is complete working code:
[VB.NET]
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
InitGrid()
End Sub
'----Private declarations
Private myDataSet As DataSet
Private mCol As DataColumn
Private dCol As DataColumn
'-----------Preparing Dataset
Private Sub PrepareDataSet()
myDataSet = New DataSet(\"MasterDetail\")
'1 table
Dim mTable As DataTable = New DataTable(\"Master\")
mCol = New DataColumn(\"BatchNumber\", GetType(System.Int32))
mCol.Unique = True
mTable.Columns.Add(mCol)
mTable.Columns.Add(New DataColumn(\"NumberOfItems\", GetType(System.Int32)))
mTable.Columns.Add(New DataColumn(\"Amount\", GetType(System.Int32)))
Dim i As System.Int32
For i = 0 To 10
mTable.LoadDataRow(New Object() {i, 12, 15}, True)
Next i
'2 table
Dim dTable As DataTable = New DataTable(\"Detail\")
dCol = New DataColumn(\"BatchNumber\", GetType(System.Int32))
dTable.Columns.Add(dCol)
dTable.Columns.Add(New DataColumn(\"ControlNumber\", GetType(System.Int64)))
dTable.Columns.Add(New DataColumn(\"Amount\", GetType(System.Int32)))
Dim j As System.Int32
For i = 0 To 10
For j = i + 2 To 12
dTable.LoadDataRow(New Object() {i, j, 12}, True)
Next j
Next i
'add tables
myDataSet.Tables.AddRange(New DataTable() {mTable, dTable})
'add relations
Dim relation As DataRelation = New DataRelation(\"Master_Detail\", mCol, dCol)
myDataSet.Relations.Add(relation)
End Sub
'--------------FlyGrid initialization
Private Sub InitGrid()
'create and init dataset
PrepareDataSet()
'add columns to the master .Columns
Dim col As Column
For Each dc As DataColumn In myDataSet.Tables(\"Master\").Columns
'if it is master column - add Hierarchycolumn to show +/- buttons
If dc Is mCol Then
Dim hc As HierachyColumn
hc = New HierachyColumn(dc.Caption)
hc.ShowOutline = True
hc.TextAlign = ContentAlignment.MiddleRight
col = hc
Else
col = New Column(dc.Caption)
End If
flyGrid1.Columns.Items.Add(col)
Next
'add columns to detail columns - .Columns.NestedColumns
For Each dc As DataColumn In myDataSet.Tables(\"Detail\").Columns
If (Not dc Is dCol) Then 'skip detail/column
col = New Column(dc.Caption, dc.ColumnName)
flyGrid1.Columns.NestedColumns.Items.Add(col)
End If
Next
'bind FlyGrid
flyGrid1.Rows.DataSource = myDataSet
flyGrid1.Rows.DataMember = \"Master\"
End Sub