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

Help me understand: DataGrid, returning row clicked

I used this solution:
http://msdn.microsoft.com/library/de...omDataGrid.asp

I added the code to my program. And it works great.

What I don't understand is the last part:

this.myDataGrid.MouseDown += new
System.Windows.Forms.MouseEventHandler
(this.myDataGrid_MouseDown);

Of course, I changed "myDataGrid" to the name of the datagrid I'm
using. It works like a charm!

Could someone please help me understand that this code did?
Thanks,
Andrew

Nov 16 '05 #1
3 993
Hello!
This line of code is registering MouseDown event for the DataGrid. you
will also need a method with signature
private void myDataGrid_MouseDown(object sender,MouseEventArgs e)
obviously you'll need it only if you want to do something when Mouse
button clicks on DataGrid. Otherwise its not at all necessary. If you
are working on events registration from IDE, it'll automatically add
this line to you code. (Analyze Windows Form Designer Generated code).
this.myDataGrid.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.myData Grid_MouseDown);
Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
Thanks for the response!

I think I got it. Am I right in understanding that the += adds this
event to previously defined events?

-a

Nov 16 '05 #3
Actually += is used to consume an event. In other words it wires the
event with your object by creating instance of the appropriate delegate.
-= unwires it. '+=' and '-=' function for events is a bit different than
as an assignment operator.

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

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

Similar topics

1
by: Daily | last post by:
How to get text from clicked HyperLink in Datagrid? and Is possible returning to another aspx file? how?
4
by: Randy | last post by:
I have a DataTable in a DataGrid. If I click on the DataGrid, HitTestInfo in dataGrid1_MouseDown returns a Row and Column number. I can use the Row number to say: DataRow dr = dataTable.Rows;...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
0
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
0
by: richard | last post by:
OK, Im finished pulling my hair out and now I need help. I have created a VB class file for my custom paging, in it I create a table with 2 rows, in the rows I have linkbuttons for first page,...
1
by: Jason Huang | last post by:
Hi, In the code: DataGrid.HitTestInfo hti = dataGrid.HitTest( e.X, e.Y ); dataGrid = ! (bool) dataGrid; Would someone tell me what the line doing: DataGrid.HitTestInfo hti =...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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
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
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.