Re: Problems setting up datagrid

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ron L (ronl_at_bogus.Address.com)
Date: 09/17/04


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
>
>
>
>



Relevant Pages

  • Re: Problems setting up datagrid
    ... > from a SQL Stored Procedure in a different order form how SQL returns it, ... but it is showing up last. ... > showing up as simple text boxes, ... > Ron L ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using combo box selection to supply criteria for query
    ... Sorry, I am still learning SQL and VBA, I don't think that I made the ... The form contains 5 combo boxes; SBT Account, Region, ADM, Month, Year ... If I only make a selection in the Region combo box ... Post the query SQL. ...
    (microsoft.public.access.forms)
  • RE: MERGE 2 FILES
    ... How about with no SQL to type? ... Once MS Query displays the data ... \Select the rngCourseInstr range and click ... "Ron Coderre" wrote: ...
    (microsoft.public.excel.misc)
  • RE: passing data to new form using open args
    ... If the SQL you are trying to send to the form is the data you want for your ... As to the SQL you have for your combo boxes. ... Row Source type to Table/Query and put the SQL in the Row Source property. ...
    (microsoft.public.access.formscoding)
  • Re: QUERY - AND/OR for search panel
    ... Here is the SQL that got the job done. ... FOR an AND Query between five boxes: ... An easier solution would be to build the WHERE clause ...
    (microsoft.public.access.queries)