Results 1 to 8 of 8

Thread: [RESOLVED] DGV Woes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Resolved [RESOLVED] DGV Woes

    I have an outstanding issue with a DGV which I said was resolved in a previous thread, which turned out not to be. The issue is this:

    I have a DGV in which the virtual mode is set to true as I do my own data management. The problem I am getting is when I have added a new row to the data grid and saved it successfully, and then try to list another set of data I get an error as shown. If I edit a cell anywhere in the datagrid and save it, I can list another set of data successfully. Ignore blank cells as this does not cause any problems.

    The value in the combo box is added to a hidden cell in the datagrid when a new row has been added. I have 2 SQL statements for the dataadapter, one to list the data and one for saving. I have also provided the code with this problem. Can anyone provide with a solution with or without the vitual mode set to true as I will have similar types of layouts in other parts of the application.

    Computerman
    Attached Images Attached Images   
    Attached Files Attached Files
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  2. #2
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: DGV Woes

    sounds like something is declared but currently = nothing

    I have not looked @ your code tho - check the RoomPricingDGV and txtRoomType also roomPricingDGV.curr....Value - highlight these bits and press shift F9 On them

    Kris

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DGV Woes

    Are you sure that there's a column in that grid named "RoomType"? It doesn't look like there is to me.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: DGV Woes

    There is a is a column called RoomType but it is hidden.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DGV Woes

    Working out why might be more difficult but working out which reference is Nothing is very simple, and that's what you need to do first. You can't solve the problem if you don;t know what problem you're solving. You can use the Immediate window, the Watch window, the Quick Watch window or simply select the reference and mouse over it to see it's value. Just start at the first reference on the line and keep going until you find one that's Nothing. You then work backwards to where you expected a value to be assigned to that reference.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: DGV Woes

    I have checked the variable txtRoomType and there is a value associated to it. Can you give me a greater explination of the error as I am having trouble understanding what MSDN is trying to explain.

    What is still confusing me is that the problem only occurs once a new datarow has been added to the grid. At all other times (ie editing, deleting and scrolling through the combobox), it behaves as it should.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: DGV Woes

    I have checked the variable txtRoomType and there is a value associated to it. Can you give me a greater explination of the error as I am having trouble understanding what MSDN is trying to explain.

    What is still confusing me is that the problem only occurs once a new data that I have entered has been added to the grid and saved. At all other times (ie editing, deleting and scrolling through the combobox), it behaves as it should.

    Computerman :confused
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: DGV Woes

    I finally solved it. I had gone about it the wrong way. I reset the VIRTUALMODE for the Datagrid to false, removed NEWROWNEEDED & ROWSADDED events and used the USERADDEDROW event instead. Now everything works the way it should.

    Many thanks to everyone who tried to help.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

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