473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sort datagrid (ThreadSystem.NullReferenceException in system.windows.forms.dll)

Please help

I have the problem that when I change the data in a
Windows.Forms.DataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.NullReferenceException in
system.windows.forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben

Nov 20 '05 #1
3 2361
Hi Ben,

No takers with just the message. I reckon you're gonna have to send that
Project.

Regards,
Fergus
Nov 20 '05 #2
On 2003-10-30, mahtan <Be***********@hotmail.com> wrote:
Please help

I have the problem that when I change the data in a
Windows.Forms.DataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.NullReferenceException in
system.windows.forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben


Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
* Tom Shelton <to*@mtogden.com> scripsit:
Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.


A good introduction to Windows Forms + Multithreading can be found here:

<http://www.devx.com/dotnet/Article/11358>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: wesley | last post by:
Hi all, I have been getting this frustating problem where my application keep throwing a NullReferenceException, but for the light of me I could not localise the location of the problem since it...
0
by: sarah | last post by:
Using .NET C# installed Framework 1.1 with Service Pack 1 I have a MDI application in C# that contains 3 different forms. Form 1 has several controls one of which is a DataGrid control that...
2
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
3
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control,...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
0
by: Becker | last post by:
I have a datatable that I use to display running processes. These running processes are spawned as different threads. I use the readerwriterlock class to ensure that when I write to the datatable,...
2
by: Flack | last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable with the appropriate columns and use it for the DataGrids.DataSource. Later on in my app, I alter the DataTable: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.