Results 1 to 5 of 5

Thread: form.showDialog()

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    form.showDialog()

    I have three forms: A, B and C

    There is a button on A to load B, and a button on B to load C, which has a datagrid with checkbox column.

    I use showDialog() to load the forms.

    When I click the checkbox on C's datagrid, i get error on A's button click event "An unhandled exception of type 'System.InvalidCastException' occurred in system.windows.forms.dll

    Additional information: Specified cast is not valid."

    Any idea? Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Yes! Vb.NET has a particular and misterious way to show its errors.
    The error is probably in the code of Form C, as you can imagine, but when forms are showed as Modal (like ShowDialog), VB.NET make green the code line in which the form is showed. I don't know why, but I've verified this. You have to follow your application step by step and you will catch the mistake.
    Good job!
    Live long and prosper (Mr. Spock)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    Thanks for your reply.

    Yes, i think the error is about Form C. in particularly, the bool column in that datagrid. The first time i click the checkbox, it is ok, but if i check again,

    Here is the code for that boolean column:



    VB Code:
    1. Dim activeCol As DataGridBoolColumn = New DataGridBoolColumn()
    2.         activeCol.MappingName = "Active"
    3.         activeCol.HeaderText = "Active"
    4.         activeCol.AllowNull = False
    5.         activeCol.FalseValue = CShort(0)
    6.         activeCol.ReadOnly = False
    7.         activeCol.TrueValue = CShort(1)
    8.         activeCol.Width = 100
    9.         activeCol.Alignment = HorizontalAlignment.Center
    10.         dgts.GridColumnStyles.Add(activeCol)

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I must stop here, because I've never used a datagrid! Anyway the kind of error says to us that your application is trying to put a certain type of data in a place that is made for a different one, or something like this!
    Good job
    Live long and prosper (Mr. Spock)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    thank you, alextyx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width