473,779 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2984
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
1585
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 new set of data, all is okay showing the new rows of data. But when I go back to the first set of data, I get the correct data except for ONLY the second column of the first row contains the data from the second set of data. If I cause it to...
10
13358
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 that sort and one row for filtering and the lower one with no header for the data. Only it is very complicated to work this way cause for example when the user click on sort on the upper datagridview I need to sort the lower grid and so on when...
0
1180
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, and click on one of the rightmost cells the form scrolls to the leftmost end of the datagridview. I tried various permutations of the form's autoscroll, the datagridview's scrollbars, and the datagridview's selection mode without success. What do...
10
45215
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 event..., to no avail Any ideas Regards
2
9423
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? Thanks
0
2165
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 is immediately below the Top Left Corner Select All cell. When clicking on the Top Left Corner SelectAll cell, which selects all the Rows/columns in the datagridview, the only event that appears to fire is the SelectionChanged event. But that...
0
3029
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 = icon.ToBitmap(); But how do I put one into the column header cell? Thanks, Mattias
12
13647
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 display in a textbox below the datgridview. I currently have it fixed so if you click on a row the note field from that row is put in the textbox. I'd like this to be automatic as they move through rows. Also the note field is one of two fields...
4
26879
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 = true; When I add another entry to the datagrid, I return to this routine and check for the current row as follows: DataGridViewRow row = dataGridView2.CurrentRow;
0
9633
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8959
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7483
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.