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

Select cell problems with DataGridView in csharp

Hi all,

I'm reasonably new to csharp so you have to forgive me asking what may
be a stupid question...

As I said, I'm new to CSharp but in VB I was able to click anywhere on
a DataGridView (so long as it was on a cell or header) and return the
value contained in the first column for the selected row and store that
as a variable or in a textbox.

However, after building the same thing in CSharp if I click on the
cell, but in white space after the value contained in the cell, the
method fails to fire, even though the cell has clearly changed. If I
click on the value in the cell, the method does fire and the value in
the first column of that row is returned.

Is this a bug in CSharp (2005) or am I doing something wrong?

Jul 6 '06 #1
2 2962
I found out why this is happening, but not sure how the situation
arose?

In the form designer file there was no line which defined the CellClick
event.

I really want to like CSharp and the language is already pulling me in,
but the Visual Studio 2005 environment seems to be really flakey,
unless I am missing the point on some of these 'issues' ?

In VB, when I look at the code for a form, I can choose a control and
then choose its events from drop downs at the top of the screen. These
seem to be different in CSharp and this is making the transition from
VB to CSharp a little more difficult than I had hoped!

My fault entirely of course... I'll shut up now!

Karl wrote:
Hi all,

I'm reasonably new to csharp so you have to forgive me asking what may
be a stupid question...

As I said, I'm new to CSharp but in VB I was able to click anywhere on
a DataGridView (so long as it was on a cell or header) and return the
value contained in the first column for the selected row and store that
as a variable or in a textbox.

However, after building the same thing in CSharp if I click on the
cell, but in white space after the value contained in the cell, the
method fails to fire, even though the cell has clearly changed. If I
click on the value in the cell, the method does fire and the value in
the first column of that row is returned.

Is this a bug in CSharp (2005) or am I doing something wrong?
Jul 7 '06 #2
In VS you can select an object, then in the properties window (at the
top) you can choose to see properties (default) ,events (by selecting
the lightning bolt), etc...

To get the functionability you are looking for, I believe you want to
look into tablestyles and you will also want to probably use the
oncellchange event...

Karl wrote:
I found out why this is happening, but not sure how the situation
arose?

In the form designer file there was no line which defined the CellClick
event.

I really want to like CSharp and the language is already pulling me in,
but the Visual Studio 2005 environment seems to be really flakey,
unless I am missing the point on some of these 'issues' ?

In VB, when I look at the code for a form, I can choose a control and
then choose its events from drop downs at the top of the screen. These
seem to be different in CSharp and this is making the transition from
VB to CSharp a little more difficult than I had hoped!

My fault entirely of course... I'll shut up now!

Karl wrote:
Hi all,

I'm reasonably new to csharp so you have to forgive me asking what may
be a stupid question...

As I said, I'm new to CSharp but in VB I was able to click anywhere on
a DataGridView (so long as it was on a cell or header) and return the
value contained in the first column for the selected row and store that
as a variable or in a textbox.

However, after building the same thing in CSharp if I click on the
cell, but in white space after the value contained in the cell, the
method fails to fire, even though the cell has clearly changed. If I
click on the value in the cell, the method does fire and the value in
the first column of that row is returned.

Is this a bug in CSharp (2005) or am I doing something wrong?
Jul 7 '06 #3

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

Similar topics

1
by: Hans | last post by:
I have a Windows.Forms.Form containing a DataGrid where the DataSource is a DataView. Everything refreshes fine after adding, deleting or editing rows. When I close the dialog and reopen it with a...
10
by: milk-jam | last post by:
I'm trying to set my datagridview so that the first row will be left blank and to use it as a filtering filed for the datagridview. Until now I was using 2 datagridview the upper one with a header...
0
by: Christopher Lusardi | last post by:
Hello, I have a datagridview that is too wide for the form, so I'm trying to put scrollbars on the form and the datagridview table. But, when I run the application, look at the rightmost cells,...
10
by: steve | last post by:
Hi All I would like to be able to change the cell borders on certain cells to none at runtime to make a group of cells appear to be merged I have tried the following in the cellformatting...
2
by: martin1 | last post by:
Hi, All, The datagridview auto-select first column first row data and the slected cell background color is blue, so how to turn off the select? or how to change selected cell backcolor to white?...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
In a datagridview, the first column header cell is columnHeader(0), which is immediately to the right of the Top Left Corner Select All cell. And the first RowHeader cell is RowHeaderCell(0) which...
0
by: Simonsson | last post by:
I'm trying (using C#) to put an image (Icon or Bitmap maybe) in the column header cell of a DataGridView. I have no problems putting images in other cells. I do that like this: myDataRow =...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
4
by: =?Utf-8?B?UGFycm90?= | last post by:
I cannot programmatically select a row in datagridview control. I use the following instruction to change the selection of a row dataGridView2.ClearSelection(); dataGridView2.Rows.Selected =...
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: 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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.