Solved

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

Posted on 2006-10-25
12
445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

623 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