C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Catch the click event on the title row (grid.row = 0)

rated by 0 users
This post has 7 Replies | 1 Follower

Top 75 Contributor
Posts 69
jorgebastos Posted: Mon, Jun 15 2009 9:40 AM

Hi,

I'd like to catch the click on the header row, the first on the datagrid, but it doesn't seems to allow me doing that, first cause i can see the cursor on the data row's and it never leaves there.
What i'm trying to achieve is:

Private Sub grid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grid.Click

if grid.row = 0

MsgBox(grid.Cols(grid.Col).Name) 

end if 

End Sub 

 

No way that i can get this to work? What i want is to catch the column name of the header row where i have clicked.

Jorge, 

Top 25 Contributor
Posts 372

 Hello Jorge,

I was able to accomplish this in the BeforeSort event.  I am attaching a sample that illustrates this.  Please note, that this way will essentially disable column sorting.  If this presents a problem or is not what you are looking for, please let me know.  I hope this helps.

Regards,

-Raleigh

Top 75 Contributor
Posts 69

Hi there,

Thanks, it's ... almost this!

With this i can fill a variable with the columns names and then refill the grid by that order, i wanna to do it by:

1-Press CTRL
2-Click the columns that i want to sort to
3-Release CTRL, and hwre on release, refill the grid

But when i press CTRL, the sortcolumn event doesn't seem to fire, am i correct? 

Top 25 Contributor
Posts 372

Hello Jorge,

Place a breakpoint on the following line in the BeforeSort event:

 e.Cancel = True;

When you run the program you will see that the event fires when pressing CTRL.  I'm not exactly sure what you are trying do other than that, but it sounds as though you need to handle the C1FlexGrid's KeyUp and KeyDown events.  I hope this helps.

-Raleigh

Top 75 Contributor
Posts 69

Doesn't work, check this on the beforesort() event:

--- 

 MsgBox("ai")
 e.Cancel = True

' some code 

---

The msgbox() doesnt appear when i press CTRL and click on the grid's header.
If you try to do this on the sample i sent me it doesn't work either.
 

Top 25 Contributor
Posts 372

Hello Jorge,

I tried this again and I believe you are correct, the event does not fire.  I am attaching a different sample for you to look at that is fairly different.  This sample makes use of four events (KeyUp, KeyDown, BeforeSort, and MouseDown).  I hope this helps.

Regards,

-Raleigh

Top 75 Contributor
Posts 69

Well, it's this what i want!

Im just going ask you one thing, i'm having some problems converting it to vb.net, could you post a sample in vb?

Jorge, 

Top 25 Contributor
Posts 372

 Hello Jorge,

I'm glad I could help!  Here is the sample in Visual Basic.

Regards,

-Raleigh

Page 1 of 1 (8 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.