473,385 Members | 1,342 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.

Can I override DataGrid's mouse events?

Is it at all possible to override the default behavior of a DataGrid when the
mouse is clicked on a row? I am having a problem where I am trying to select
multiple rows in a DataGrid by left-clicking them, but each time I click
another row to add it to the selection the previously added row loses it's
highlighting, so it appears as though only one row is selected at any one
time.

Nov 16 '05 #1
1 3367
Update:

I made my own DataGrid extension and override the onMouseUp and onMouseDown
events. I then put in my own code which is supposed to make it so the user
can select multiple rows by clicking them one by one while holding the CTRL
key (and they all stay highlighted until they de-select them-- much like how
Windows Explorer works)

But now I lost all the other behavior of DataGrid which I want (click column
header to sort, resize columns). Using a .NET Resource tool a guy two
threads up from me suggested (so I can see DataGrid's source) helps alot to
see what DataGrid was doing but I can't simply copy the behavior I want from
these methods because certain properties and methods it uses has private
access.

The only thing that preventing my selection goal from working was one line
of code in the onMouseDown method of DataGrid which resets the selection (so
any previous row loses it's selection once I CTRL + left-click another row) I
wish I can just copy the whole method but comment out that one line but
again, because of access level restrictions I have no such luck.

So is my only choice to reinvent the wheel in regards to the other DataGrid
behavior I need (column resize, sorting) if I want my custom selection
behavior to work?
Nov 16 '05 #2

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

Similar topics

1
by: MrNobody | last post by:
How can I customize DataGrid so that when the mouse hovers over certain columns the cursor changes to the Cursors.Hand cusror? I was unable to use the MouseEnter/MouseLeave events on DataGrid...
0
by: Lalit Bhatia | last post by:
Hi, In Datagrid, while setting width of column through GridColumnStyles collection. width does not set to exact width that I am setting in my code. If I set width to 13, it is changed to 130 or...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
3
by: Charles Law | last post by:
In a user control, is it possible to replace the default mouse events with my own? In particular, I want the consumer of my control to get MouseMove events when the mouse is over my control, so...
4
by: Fred Nelson | last post by:
Hi: I have a VB.NET web app that contains a datagrid on a web form that is loaded as follows: DataGrid1.DataSource = lookup.searchnames(getinformation) DataGrid1.DataBind The grid displays...
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
2
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data...
0
by: WhiteWizard | last post by:
I am trying to implement standard multi-select of rows in a datagrid. That is, allow the user to use the CTRL & SHIFT keys to select multiple rows in a datagrid. Then I'll loop through them and...
1
by: DaveS | last post by:
I am trying to capture the mouse click position in a datagrid but I get the following compilation error: Compiler Error Message: BC30002: Type 'System.Windows.Forms.MouseEventArgs' is not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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...

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.