473,396 Members | 1,892 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,396 software developers and data experts.

Is something wrong with datagrid.rows.clear()?

Here's my code. When i try to call it from serialport.DataReceived event i
got random errors. One of them is that object reference is not set to an
instance of an object : in Application.Run(new Form1()) <- I don;t know even
why here. Like program wants to start again.

Anyway Rows.Clear() seems to cause the errors.
public void Fill_DataGrid()
{
ArrayList list = configFile.loadAllValues();

if (list != null)
{
string b = null, pat = null ;

dataGridView1.Rows.Clear();

foreach (String var in list)
{
b = var.Substring(0, var.IndexOf(' '));
pat = var.Substring(var.IndexOf(' '),
var.IndexOf("<p>") - var.IndexOf(' '));

if (var.Contains("."))
{
pat = Path.GetFileName(pat);
pat += " " + var.Substring(var.IndexOf("<p>") + 3);
}

int p = dataGridView1.Rows.Add();
dataGridView1.Rows[p].Cells[0].Value = b;
dataGridView1.Rows[p].Cells[1].Value = pat;
}
}

}
For any help really really thanks
Piotr
May 21 '06 #1
6 3495

"PiotrKolodziej" <pi*************@gmail.com> wrote in message
news:35***************************@news.chello.pl. ..
Here's my code. When i try to call it from serialport.DataReceived event i
got random errors. One of them is that object reference is not set to an
instance of an object : in Application.Run(new Form1()) <- I don;t know
even why here. Like program wants to start again.

....

Check:
http://msdn2.microsoft.com/en-us/lib...areceived.aspx

under remarks section... You may access UI elements only from main thread,
but datareceived evnet is raised from secondaty thread.

Goran

May 21 '06 #2
Then maybe you will help me to create Delegate for Datagird.rows.Clear()?

I tried to create delegate in this way

public Delegate myDelegate(object ob1);

i got

Error 1 'IRDAcontrol.Form1.myDelegate(object)' must declare a body because
it is not marked abstract or extern C:\Documents and Settings\test\My
Documents\Visual Studio 2005\Projects\IRDAcontrol\IRDAcontrol\Form1.cs 225
25 IRDAcontrol
If i succed i can try

myDelegate a = myDelegate(dataGridView1.Rows.Clear());

and then use

datagrid.invoke(a)
Am i right?
May 21 '06 #3
PiotrKolodziej wrote:
Then maybe you will help me to create Delegate for Datagird.rows.Clear()?

I tried to create delegate in this way

public Delegate myDelegate(object ob1);
Change "Delegate" to "delegate" and add "void" as data type.

As the compiler doesn't recognise "Delegate" as a keyword, it assumes
that it is the data type of the return value from the method.
i got

Error 1 'IRDAcontrol.Form1.myDelegate(object)' must declare a body because
it is not marked abstract or extern C:\Documents and Settings\test\My
Documents\Visual Studio 2005\Projects\IRDAcontrol\IRDAcontrol\Form1.cs 225
25 IRDAcontrol
If i succed i can try

myDelegate a = myDelegate(dataGridView1.Rows.Clear());

and then use

datagrid.invoke(a)
Am i right?

May 21 '06 #4
> As the compiler doesn't recognise "Delegate" as a keyword, it assumes that
it is the data type of the return value from the method.


What should i write instead of:

myDelegate a = myDelegate(dataGridView1.Rows.Clear());

It asks me for methodname.....
Anyway you have been very helpful and thanks a lot.

Piotr
May 21 '06 #5
On Mon, 22 May 2006 00:48:27 +0200, "PiotrKolodziej"
<pi*************@gmail.com> wrote:
As the compiler doesn't recognise "Delegate" as a keyword, it assumes that
it is the data type of the return value from the method.


What should i write instead of:

myDelegate a = myDelegate(dataGridView1.Rows.Clear());

It asks me for methodname.....
Anyway you have been very helpful and thanks a lot.

Piotr

Hi Piotr

You should replace

dataGridView1.Rows.Clear()

in the line

myDelegate a = myDelegate(dataGridView1.Rows.Clear());

with a method you have created yourself and add the new keyword, e.g

private void ClearReplacementFunc()
{
// do stuff
}

the line of code would then look like

myDelegate a = new myDelegate(ClearReplacementFunc);
hope this helps

Steve

http://www.pretty-vacant.co.uk
May 22 '06 #6
Ill try - Thank you
May 22 '06 #7

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

Similar topics

4
by: Weeepie | last post by:
Hello, Is it possible to clear a datagrid in VBdotNET? I'm using a query to fill the datagrid, but when I change the parameter, the next query follows the previous. Is there someone who can...
4
by: Mike L | last post by:
This is for a Win form. How do I clear all the rows in a datagrid? How do I add a record to a datagrid?
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
by: Matt | last post by:
I have a datagrid that gets a SQL query returned containing one column that is XML. While I build the datagrid I have to split and parse the XML to get the information that I want for each row. ...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
6
by: simchajoy2000 | last post by:
Hi, I know there are a lot of postings out there concerning this subject already, but so far I have not discovered anything that meets my specific needs. Everything I have found populates the...
8
by: mark | last post by:
What I have is three forms. Form one with buttons 1, 2 and 3; and forms 2 and 3 with datagrids. Button 1 populates arrays a(i,j) and b(i,j) with values. Button 2 creates a datatable containing...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
1
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.