I am attempting to set up a datagrid that will 1) display a subset of data
from a SQL Stored Procedure in a different order form how SQL returns it,
and 2) display 3 of the columns using pulldowns. I have gotten code for
both from the www.syncfusion.com site, but am having trouble making them
work. Below is the relevant code:
' Setup the permissions grid
' Fill the dataset of permissions
Dim dt As DataTable = dsUserData.Tables(0)
' Remove the table columns we don't want to have in the grid
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(5)
dt.Columns.RemoveAt(0)
dt.Columns.RemoveAt(0)
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "permissions"
' Setup the Subsystems column
Dim TextCol As New DataGridTextBoxColumn
TextCol.MappingName = dt.Columns(3).ColumnName
TextCol.HeaderText = dt.Columns(3).ColumnName
tableStyle.GridColumnStyles.Add(TextCol)
' Setup the permissions columns
Dim i As Integer
For i = 0 To 2
Dim ComboTextCol As New DataGridComboBoxColumn
ComboTextCol.MappingName = dt.Columns(i).ColumnName
ComboTextCol.HeaderText = dt.Columns(i).ColumnName
ComboTextCol.Width = 120
ComboTextCol.ColumnComboBox.Items.Clear()
ComboTextCol.ColumnComboBox.Items.Add("0")
ComboTextCol.ColumnComboBox.Items.Add("1")
ComboTextCol.ColumnComboBox.Items.Add("3")
ComboTextCol.ColumnComboBox.Items.Add("7")
' ComboTextCol.ColumnComboBox.Items.Add("No Access")
' ComboTextCol.ColumnComboBox.Items.Add("Guest")
' ComboTextCol.ColumnComboBox.Items.Add("Operator")
' ComboTextCol.ColumnComboBox.Items.Add("Manager")
tableStyle.PreferredRowHeight =
ComboTextCol.ColumnComboBox.Height + 2
tableStyle.GridColumnStyles.Add(ComboTextCol)
Next
grdPermissions.TableStyles.Clear()
grdPermissions.TableStyles.Add(tableStyle)
grdPermissions.DataSource = dt
' MsgBox(grdPermissions.TableStyles(0).MappingName)
dsUserData is already setup and is being used to also fill some text boxes
on the form, so I know that it is fine, and I have as part of my project the
DataGridComboBoxColumn.vb class that is defined in the syncfusion web site.
From what I have been able to find, the "Setup Subsystems" section should
make that column be the first in the grid because it is defined first in the
TableStyle, but it is showing up last (as it was in the original dataset).
Also, the 3 column that are setup under "Setup the permissions columns" are
showing up as simple text boxes, not as combo boxes. Can anyone see what I
am doing wrong here?
TIA
Ron L