Re: Problems setting up datagrid
From: Ron L (ronl_at_bogus.Address.com)
Date: 09/17/04
- Next message: Ron L: "DataGrid Combo Box problem"
- Previous message: Jerry Spence1: ""Windows Forms" Toolbox vanished"
- In reply to: Ken Tucker [MVP]: "Re: Problems setting up datagrid"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Sep 2004 06:18:22 -0400
Ken
Thanks for the response. I tried that change and get the following
error message when I open the form:
An unhandled exception of type 'System.InvalidCastException'
occurred in system.windows.forms.dll
Additional information: Specified cast is not valid.
I don't know where the table name would come from, but the contents of this
dataset is the results set returned from calling a SQL 2k stored procedure
that does a select on a number of tables using JOIN statements. Do you have
any further suggestions?
Thanks,
Ron L
"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
news:%231eqboCnEHA.3172@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Sounds like it is not using your table style. The mapping name is
> wrong. Try this instead.
>
>
> tableStyle.MappingName = dt.tablename.tostring
>
>
> Ken
> --------------------------
> "Ron L" <ronl@bogus.Address.com> wrote in message
> news:uQzponAnEHA.744@TK2MSFTNGP10.phx.gbl...
> 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
>
>
>
>
- Next message: Ron L: "DataGrid Combo Box problem"
- Previous message: Jerry Spence1: ""Windows Forms" Toolbox vanished"
- In reply to: Ken Tucker [MVP]: "Re: Problems setting up datagrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|