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

---------------------------
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
LVL 12
ullfindsmitAsked:
Who is Participating?
 
kodiakbearConnect With a Mentor Commented:
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0
 
Kinger247Commented:
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
 
ullfindsmitAuthor Commented:
but it is not binding teh grid 100 times a second... remeber its a windows form...
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
newyuppieCommented:
does the code work if you dont do it 100 times a second?
0
 
Kinger247Commented:
Yes, I'm confused now as to whats running 100 times. If its not the code above what is it ?
0
 
GilesBathgateCommented:
You have a bug, its probably due to pressing teh keys in teh wrong order.
0
 
newyuppieCommented:
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
 
ullfindsmitAuthor Commented:
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
 
newyuppieCommented:
have you found it? post the complete code for the form, can you?
0
 
ullfindsmitAuthor Commented:
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
 
ullfindsmitAuthor Commented:
http://www.dotnet247.com/247reference/msgs/41/205926.aspx
is the solution.

thanks for your help though
0
All Courses

From novice to tech pro — start learning today.