|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Event not firingI've got the following code for a datagridview :
private void grdMain_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { Console.WriteLine(e.X.ToString() + ", " + e.Y.ToString()); } It never gets called, depite frantic clicking! Am I missing something? Thanks <pba***@recoilsoft.com> wrote in message
news:1155294166.136288.16590@p79g2000cwp.googlegroups.com... Send also where you have define mousevenethandler for that event... I don't > I've got the following code for a datagridview : > > private void grdMain_MouseDown(object sender, > System.Windows.Forms.MouseEventArgs e) > { > Console.WriteLine(e.X.ToString() + ", " + e.Y.ToString()); > } > > It never gets called, depite frantic clicking! Am I missing something? > > Thanks > know what you trying to to, but usually I don't use MouseDown click instead MouseUp event. D.S. Hi,
The handler is : this.grdMain.MouseDown += new System.Windows.Forms.MouseEventHandler(this.grdMain_MouseDown); The reason Im doing this is that I'm attempting to detect whether the user is trying to sort a column on the grid so that I can intercept it and put my own sort code in. If there is a more appropriate event that I should be detecting for this.. I'm open to ideas! Many thanks pba***@recoilsoft.com wrote:
> Hi, If you're using .NET 2.0 and DataGridView, you should see the > The handler is : > > this.grdMain.MouseDown += new > System.Windows.Forms.MouseEventHandler(this.grdMain_MouseDown); > > The reason Im doing this is that I'm attempting to detect whether the > user is trying to sort a column on the grid so that I can intercept it > and put my own sort code in. > > If there is a more appropriate event that I should be detecting for > this.. I'm open to ideas! DataGridView.SortCompare event to manually sort elements in a DataGridView. If you're using a DataGrid (.NET 1.x), then you have to do something else - I can't help you with that though, as I never made friends with DataGrid. -cd Carl,
Thanks for that, unfortunately I'd already taken a look at SortCompare in MSDN and it would have been perfect, but I discovered that it doesn't fire when the grid's datasource is set. Incidentally, it's a datagridview in .NET 2.0 and it's bound to a datatable with one columns sortmode set to 'programmatic'. I recoded the mousedown stuff from scratch and miraculously it now works! (Must have had a typo in there somewhere). Now I just need to correctly work out whether the coords are over that particular column header. Many thanks |
|||||||||||||||||||||||