473,327 Members | 2,103 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,327 software developers and data experts.

intercepting datagrid column header click? Bug?

VMI
My Windows datagrid has two columns: one with the data that the user will
see (col_X) and the other one (a hidden one: col_sort) that'll be used to
sort data. When a user clicks on col_X's column header, I'm intercepting the
header click and "telling" it to sort the dataview using col_sort. But for
some reason, the "return" is not being executed. When I press the mouse key,
it'll sort correctly (by col_sort), but as soon as I release the button,
it'll sort by col_x. This is my code:

private void dataGrid_browse_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hitTest;
if (e.Button == MouseButtons.Left)
{
hitTest = dataGrid_browse.HitTest(e.X, e.Y);
if (hitTest.Type == DataGrid.HitTestType.ColumnHeader)
{
DataView dtView = (DataView)dataGrid_browse.DataSource;
if (hitTest.Column == 4) //column 4 is col_X
{
dtView.Sort = "col_sort ASC";
return; //without messageBox or breakpoint , this
instruction is ignored
}
}
}
}

If I put a breakpoint or put a Messagebox inside the "if (hitTest.Column ==
4)" (I force the program to pause), it'll work. But if it does it
continuously, it'll sort by col_sort and then sort by col_x. The "return" is
ignored.

Any help is appreciated.

Thanks.
Nov 16 '05 #1
0 1682

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

Similar topics

1
by: | last post by:
How I can autosize a DataGrid after then associate a Datasource=Dataset in Smart Devices applications or Windows forms application?? That same?? -- Cumprimentos, David de Passos...
1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
2
by: Snig | last post by:
Hi, I want to sort the DataGrid according to the number of clicks of mouse on the column-header link. e.g. if user clicks on the header once - it will be sorted ASC if the header is...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
2
by: thomasp | last post by:
I have a datagridview that allows the user to sort the column by clicking on the header of the column the user wishes to sort. I did not code this, it had the ability when the datagrid was...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
8
by: Matt | last post by:
Guys I could really use some help with this. I think that it's probably a simple solution but I haven't been able to find anything. I have a datagrid on my form that I populate via code like...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.