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

CurrentCellChanged in DatagridView

Hello, I'm a kind of newbie in C# and I've a question regarding the
DataGridView control in VS2005. The problem I have is the following:

I have a form with some labels on it, when a user clicks on it another form
is called. This last form contains a split container with in the left part a
datagridview. In the right part i've added a label which shows a value from a
column in the datagrid. So when i change the row, the label must be updated
with the value of the currently selected row. This works fine with the
currentCellChanged event. However when i press the label on the first form, i
see (via debug) that the constructor of the second form is called, in this
part i also populate the datagridview.

The steps above are done in the following code excerpt:
private void LabelHandler(object sender, System.EventArgs e) {
frmDesktop desktop = new frmDesktop(((Label)sender).Text);
desktop.Show();
}

However i have an error when the statement desktop.Show() is launched. For
some reason the currentcellchanged is called five times. When i read out the
currentCellAddress i got the following: (ps. there are currently four rows in
the grid, add row is disabled)
(X=1,Y=0)
(X=-1,Y=-1)
(X=1,Y=0)
(X=-1,Y=-1)
(X=1,Y=0)

Why is this currentCellChanged event called that often just when launching
the form?

As you can derive from the values above it's necessary to test on the
currentCellAddress values. Since the second and the fourth call result in a
nullreference exception when setting the text of label in the right to the
value of the grid

Anybody an idea what's the problem ? Or is this normal ?

Kind regards,
Tom
Dec 8 '05 #1
0 2923

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

Similar topics

1
by: Lester Moreno | last post by:
Hello all, I'm trying to find a way to get a event raised when you change some text on a DataGrid Cell, I need to be able to search in another table what the user typed on that cell. I found...
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to...
0
by: Djimbo | last post by:
How can i select another Fullrow from DataGrid in CurrentCellChanged Handler function?
1
by: J | last post by:
Hi, all I am working on a windows application which need to write to a log file if any user changed the current cell's data. I am using CurrentCellChanged property to monitor this situation. But I...
1
by: jason via DotNetMonster.com | last post by:
Hi, all I am working on a windows application which need to write 'column name', 'new data' to a log file if any user changed the current cell's data. I am using CurrentCellChanged property to...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
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:
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: 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
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.