PC Review


Reply
Thread Tools Rate Thread

Datagrid frustartions

 
 
Bill Styles
Guest
Posts: n/a
 
      22nd Jan 2004
I've been trying to do some work with a datagrid control on a winform and
have gotten very frustrated with it. I need to be able to determine when
the user clicks on a given cell but can't find anything that seems to be
reliable.

The click and doubleclick events fire when the user clicks on the row or
column headers and *sometimes* when the user clicks on a particular cell. I
can't figure out any pattern to when it fires by clicking on a cell.

The CurrentCellChanged fires when the user clicks on a cell but ALSO when
the user clicks on a different row or column header so if they select a cell
and then click a column header to sort differently then it changes the
selection. I need to identify the last cell selected only and not have it
be affected by row or column clicks.

There are a lot of other things that should be simple that the datagrid
seems to make as difficult as possible but I've managed to work around
everything so far except the ability to select a cell. Any ideas will be
appreciated.

--
C# newbie... posts are probably inaccurate, inelegant or both

 
Reply With Quote
 
 
 
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      23rd Jan 2004
Hello Bill,

Use the MouseUp event (or MouseDown, depending on what you want to do upon a
click) and then use the HitTest method on the grid instance to determine
whether the user has clicked on a cell, on a row header, on a column header
etc.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Bill Styles" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I've been trying to do some work with a datagrid control on a winform and
> have gotten very frustrated with it. I need to be able to determine when
> the user clicks on a given cell but can't find anything that seems to be
> reliable.
>
> The click and doubleclick events fire when the user clicks on the row or
> column headers and *sometimes* when the user clicks on a particular cell.

I
> can't figure out any pattern to when it fires by clicking on a cell.
>
> The CurrentCellChanged fires when the user clicks on a cell but ALSO when
> the user clicks on a different row or column header so if they select a

cell
> and then click a column header to sort differently then it changes the
> selection. I need to identify the last cell selected only and not have it
> be affected by row or column clicks.
>
> There are a lot of other things that should be simple that the datagrid
> seems to make as difficult as possible but I've managed to work around
> everything so far except the ability to select a cell. Any ideas will be
> appreciated.
>
> --
> C# newbie... posts are probably inaccurate, inelegant or both
>


 
Reply With Quote
 
Bill Styles
Guest
Posts: n/a
 
      23rd Jan 2004
"Dmitriy Lapshin [C# / .NET MVP]" <x-(E-Mail Removed)> wrote
in message news:(E-Mail Removed)
> Hello Bill,
>
> Use the MouseUp event (or MouseDown, depending on what you want to do
> upon a click) and then use the HitTest method on the grid instance to
> determine whether the user has clicked on a cell, on a row header, on
> a column header etc.


Excellent, thanks! That appears to be a viable option from the quick tests
I just did. Now I can create a wrapper that provides the events I really
need.


--
C# newbie... posts are probably inaccurate, inelegant or both

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MVVM: Single datagrid row selection when a datagrid contains anotherdatagrid in side RowDetailsTemplate Sunita@.NET Microsoft C# .NET 0 12th Nov 2010 09:03 AM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth Microsoft Dot NET Framework 0 5th Apr 2005 04:54 AM
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls thegame Microsoft ASP .NET 1 28th Feb 2005 04:23 PM
Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False Amar Microsoft ASP .NET 0 6th Apr 2004 11:14 AM
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams Microsoft ASP .NET 0 2nd Mar 2004 08:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:02 AM.