473,378 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,378 software developers and data experts.

Datagrid view problem please help me its urgent

i am getting an exception while end editing the 1st column 1st row of the cell(1,1) it is a combobox cell of datagridview everytime it showing following exception only on endedit

dont know why can anybody help me plz

"Operation not valid because it results in reentrant call to the SetCurrentCellAddress core function"

Expand|Select|Wrap|Line Numbers
  1. ArrayList taName = (ArrayList)_responseparser.tableEnum[r];
  2. ArrayList taValue = (ArrayList)_responseparser.tableValue[r];
  3. DataGridViewComboBoxCell comboCell = new DataGridViewComboBoxCell();
  4. for (int s = 0; s < taName.Count; s++)
  5. {
  6.     comboCell.Items.Add(taName[s]);
  7. }
  8. dataGridView1[1, r] = comboCell;
  9. id = (ushort)_responseparser.tableId[r];
  10. data = CommMngr.SelectedUnit.Modbus.GetParameter(id);
  11. for (int m = 0; m < taName.Count; m++)
  12. {
  13.     if (data != null)
  14.     {
  15.         if (data[0] == Convert.ToInt32(taValue[m]))
  16.         {
  17.             dataGridView1[1, r].Value = (string)taName[m];
  18.             break;
  19.         }
  20.     }
  21. }
  22.  
the bolded line arising the exception EDIT: that would be line 8

can anyone help me plz...............
Jul 17 '08 #1
6 2179
Curtis Rutland
3,256 Expert 2GB
Please use the [code] tags when posting code snippets. This makes it easier for our experts to read and understand your code, and the easier they can read it, the easier they can help with your problem. You can insert them by clicking the # button in the editor. Please read the Posting Guidelines for more information.

MODERATOR
Jul 17 '08 #2
Plater
7,872 Expert 4TB
What is this _responseparser.tableId[r]; buisness?
What type of object is _responseparser?
And the tableid[r] is?
Jul 17 '08 #3
What is this _responseparser.tableId[r]; buisness?
What type of object is _responseparser?
And the tableid[r] is?
_responseparser is a class object
and tableid[r]is a property from that class
Jul 18 '08 #4
Please help me in this Exception
Expand|Select|Wrap|Line Numbers
  1. else if (_responseparser.tableType[r].ToString() == NONENUMERICAL)
  2.             {
  3.                 dataGridView1.Rows[r].Cells[0].Value = _responseparser.tableName[r];
  4.                 int valueCount = _responseparser.tableValue.Count;
  5.                 if (valueCount != 0)
  6.                 {
  7.                     ArrayList taName = (ArrayList)_responseparser.tableEnum[r];
  8.                     ArrayList taValue = (ArrayList)_responseparser.tableValue[r];
  9.                     DataGridViewComboBoxCell comboCell = new DataGridViewComboBoxCell();
  10.                     for (int s = 0; s < taName.Count; s++)
  11.                     {
  12.                         comboCell.Items.Add(taName[s]);
  13.                     }
  14.                     dataGridView1[1, r] = comboCell;
  15.                     id = (ushort)_responseparser.tableId[r];
  16.                     data = CommMngr.SelectedUnit.Modbus.GetParameter(id);
  17.                     for (int m = 0; m < taName.Count; m++)
  18.                     {
  19.                         if (data != null)
  20.                         {
  21.                             if (data[0] == Convert.ToInt32(taValue[m]))
  22.                             {
  23.                                 dataGridView1[1, r].Value = (string)taName[m];
  24.                                 break;
  25.                             }
  26.                         }
  27.                     }
  28.                 }
  29.             }
exception is at bolded line

"Operation not valid because it results in reentrant call to the SetCurrentCellAddressCore Function"

only on editing the cell[1,1] with cell end edit
Jul 22 '08 #5
Plater
7,872 Expert 4TB
It sounds like you have a funcion that gets called when the data in a cell changes, and in that function you are setting one of the cells. I think it is sync-locking the cells implicitly and it's telling you what you are trying to do would break that sync lock.
(Like if you are using a foreach loop and try to remove something from the collection you are looping through, it gets mad)
Jul 22 '08 #6
It sounds like you have a funcion that gets called when the data in a cell changes, and in that function you are setting one of the cells. I think it is sync-locking the cells implicitly and it's telling you what you are trying to do would break that sync lock.
(Like if you are using a foreach loop and try to remove something from the collection you are looping through, it gets mad)
Expand|Select|Wrap|Line Numbers
  1. private void DataColumnAdd(int r)
  2.         {
  3.             ushort id, scalefactor;
  4.             ushort[] data = new ushort[8];
  5.             double sValue;
  6.             if (_responseparser.tableType[r].ToString() == NUMERICAL)
  7.             {
  8.                 dataGridView1.Rows[r].Cells[0].Value = _responseparser.tableName[r];
  9.                 id = (ushort)_responseparser.tableId[r];
  10.                 data = CommMngr.SelectedUnit.Modbus.GetParameter(id);
  11.                 if (data != null)
  12.                 {
  13.                     //dataGridView1.Rows[r].Cells[1].Value = data[0];
  14.                     scalefactor = ushort.Parse(_responseparser.tableScaleFactor[r].ToString());
  15.                     decimal dispValue = ((decimal)data[0] / (decimal)scalefactor);
  16.                     string decimalAdjusted = dispValue.ToString("N1");
  17.                     bool disValue = double.TryParse(decimalAdjusted, out sValue);
  18.                     if (disValue)
  19.                     {
  20.                         dataGridView1.Rows[r].Cells[1].Value = decimalAdjusted;
  21.                     }
  22.                 }
  23.                 else
  24.                 {
  25.                     dataGridView1.Rows[r].Cells[1].Value = "null";
  26.                 }
  27.                 dataGridView1.Rows[r].Cells[2].Value = _responseparser.tableUnit[r];
  28.             }
  29.             else if (_responseparser.tableType[r].ToString() == NONENUMERICAL)
  30.             {
  31.                 dataGridView1.Rows[r].Cells[0].Value = _responseparser.tableName[r];
  32.                 int valueCount = _responseparser.tableValue.Count;
  33.                 if (valueCount != 0)
  34.                 {
  35.                     ArrayList taName = (ArrayList)_responseparser.tableEnum[r];
  36.                     ArrayList taValue = (ArrayList)_responseparser.tableValue[r];
  37.                     DataGridViewComboBoxCell comboCell = new DataGridViewComboBoxCell();
  38.                     for (int s = 0; s < taName.Count; s++)
  39.                     {
  40.                         comboCell.Items.Add(taName[s]);
  41.                     }
  42.                     dataGridView1[1, r] = comboCell;
  43.                     id = (ushort)_responseparser.tableId[r];
  44.                     data = CommMngr.SelectedUnit.Modbus.GetParameter(id);
  45.                     for (int m = 0; m < taName.Count; m++)
  46.                     {
  47.                         if (data != null)
  48.                         {
  49.                             if (data[0] == Convert.ToInt32(taValue[m]))
  50.                             {
  51.                                 dataGridView1[1, r].Value = (string)taName[m];
  52.                                 break;
  53.                             }
  54.                         }
  55.                     }
  56.                 }
  57.             }
  58.             else if (_responseparser.tableType[r].ToString() == EMPTYDATASET)
  59.             {
  60.                 dataGridView1.Rows[r].Cells[0].Value = "Method";
  61.                 dataGridView1.Rows[r].Cells[0].Style.BackColor = Color.LightGray;
  62.                 dataGridView1.Rows[r].Cells[1].ReadOnly = true;
  63.                 dataGridView1.Rows[r].Cells[1].Style.BackColor = Color.LightGray;
  64.                 dataGridView1.Rows[r].Cells[1].Value = _responseparser.tableName[r];
  65.             }
  66.         }
this is the that function initially i populate a datagridview and then upon editing again i am populating datagridview, i understand ur statements,

but if i am changing the collection means it should happen when i am editing all the comboboxcells but i am getting that exception whenever i am editing comboboxcell at [1,1] everytime thats what i get confused

could u tell me where i should make changes?
Jul 23 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ComputerStop | last post by:
I am attempting to print a datagridview. I have not found any method that works successfully. Has any one been successful with this?
2
by: Bob | last post by:
I looked at the sample in the msdn january 2005 - Introducing a new datagrid, but the project downloaded failed to open. Any one can point me to a bit of code on how to go and select an image...
0
by: shukyh | last post by:
Hi all I would like to generate an HTML page from datagridview in win application (not webform). In th datagrid view I have DataGridViewCheckBoxColumn columns. How Can i do this? Thanks, Shuky
0
by: Tony A. | last post by:
I'm using VB 2005 with MS Access for as the database. I have a table (tblItem) that has two columns, ItemNum (key field) and ItemDescription. I also have a second table (tblOrdersDetail), this...
1
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How do I get the value of a checkbox in a row in a datagrid view please? I have tried many methods and nothing workds. This was so much easier in VB 6.0. THanks for any help you can give me.
1
by: sudheerk | last post by:
please give me code for tree view its urgent iam new to the programming[
1
by: radhikabista | last post by:
hey friends , i m not being able to save the updates in datagrid view when i press buttonsave_ gridview i have a class customer with two methods one to get the dataset and other to update database:...
1
mafaisal
by: mafaisal | last post by:
Hello Experts I am Using vb.net 2005 Hw To Put DateTime Picker in Datagrid view I have to sea Datetime Picker in Specified Cilomn of Datagrid I try This But The Location Hw To Change to the...
2
by: aapy | last post by:
I am trying to write a logic where upon selection of a row it should fill the form based on the value of the row selected from the datagrid view... But it is giving "select one row" message only...
0
by: dougancil | last post by:
I have two forms and I'm trying to pass a declared variable from form1 to form2 and then pass that variable in a sql query that I have in a dataset that is bound to my form. I know that my query...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.