Solved

[500] [URGENT] - A - vb.net winform datagrid dataset refresh timing

Posted on 2006-10-25
12
430 Views
Last Modified: 2011-10-03
---------------------------
Object reference not set to an instance of an object.
---------------------------
   at System.Data.DataView.GetRecord(Int32 recordIndex)

   at System.Data.DataView.IsOriginalVersion(Int32 index)

   at System.Data.DataRowView.GetColumnValue(DataColumn column)

   at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)

   at System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager source, Int32 rowNum)

   at System.Windows.Forms.DataGridTextBoxColumn.Paint(Graphics g, Rectangle bounds, CurrencyManager source, Int32 rowNum, Brush backBrush, Brush foreBrush, Boolean alignToRight)

   at System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(Graphics g, Rectangle cellBounds, DataGridColumnStyle column, Brush backBr, Brush foreBrush, Boolean alignToRight)

   at System.Windows.Forms.DataGridRow.PaintData(Graphics g, Rectangle bounds, Int32 firstVisibleColumn, Int32 columnCount, Boolean alignToRight)

   at System.Windows.Forms.DataGridRelationshipRow.Paint(Graphics g, Rectangle bounds, Rectangle trueRowBounds, Int32 firstVisibleColumn, Int32 numVisibleColumns, Boolean alignToRight)

   at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle& boundingRect)

   at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle gridBounds)

   at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)

   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

   at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

   at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

   at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

   at System.Windows.Forms.Application.Run(Form mainForm)

   at eBuilder.Apps.TransferManagerApp.modMain.main() in C:\VSS\TransferManager\TransferManagerApplication\modMain.vb:line 45
---------------------------
OK  
---------------------------











dvQueue = New DataView(modMain.objClsDSTMW.dsTransferManager.transferManagerFile, "fFileStatus<>'Success' and fFileStatus<>'Cancelled'", "fFilePriority ASC", DataViewRowState.CurrentRows)
        dgQueue.DataSource = dvQueue


the datagrid is bound to a dataset's datatable and teh table is updated via another thread in the process... this causes the above exception... the thread updates the dataset at times may be 100 times a second.. so hwo do I work arround this.

I heard of the beginudpate endupdate event but unsuccessfull in finding how to implement it.
also how to show only a few columns necessary and how to change their header.

thanks
-smit.

pelase help
0
Comment
Question by:ullfindsmit
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17807196
Are you running the : dgQueue.DataSource = dvQueue
100 times a second ?

It could be that the a thread is trying to run the code whilst already in use by another thread.

I would try locking the statment to see if it makes any difference.

ie ....

SyncLock Me
  dvQueue = New DataView(modMain.objClsDSTMW.dsTransferManager.transferManagerFile, "fFileStatus<>'Success' and fFileStatus<>'Cancelled'", "fFilePriority ASC", DataViewRowState.CurrentRows)
  dgQueue.DataSource = dvQueue
End SyncLock

Hope it helps !
0
 
LVL 12

Author Comment

by:ullfindsmit
ID: 17807214
but it is not binding teh grid 100 times a second... remeber its a windows form...
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17808491
does the code work if you dont do it 100 times a second?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 10

Expert Comment

by:Kinger247
ID: 17810169
Yes, I'm confused now as to whats running 100 times. If its not the code above what is it ?
0
 
LVL 3

Expert Comment

by:GilesBathgate
ID: 17810585
You have a bug, its probably due to pressing teh keys in teh wrong order.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17811512
can you post the code of the thread you said you use to update the table? and in which part of your code do you call the thread, is it inside any event of the datagridview?
0
 
LVL 12

Author Comment

by:ullfindsmit
ID: 17812669
alrit folks.... here's teh deal..
it was because of multiple threads I started fromt he TICK.

I got rid of that... now I have another problem... I get a BIG RED X on my DG when it updates.

I'll be looking it up online, if you can find it before I do... the points are yours.... else there will be a split for the effort.

-Smit.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17819811
have you found it? post the complete code for the form, can you?
0
 
LVL 12

Author Comment

by:ullfindsmit
ID: 17820878
there was no real fix for the problem.
Ended up decreasing the update speed on my datagrid by slowign down the process and Decreased the number of threads.

I did use this link http://www.sturmnet.org/blog/archives/2005/03/23/red-x/ as reference for some backup...

I'll leave the question open till I'm done with the project.
If anyone can find any solution I'd greatly appreciate it

Thanks
-smit
0
 
LVL 12

Author Comment

by:ullfindsmit
ID: 17900394
http://www.dotnet247.com/247reference/msgs/41/205926.aspx
is the solution.

thanks for your help though
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
ID: 17952021
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question