-
3 Attachment(s)
[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 :confused:
-
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
-
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.
-
Re: DGV Woes
There is a is a column called RoomType but it is hidden.
Computerman :confused:
-
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.
-
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 :confused:
-
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
-
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 :bigyello: