Solved

Quantum Grid: How to incorporate both column-move and a header click event?

Posted on 2009-04-02
4
1,159 Views
Last Modified: 2012-05-06
I am building an app that uses a DevExpress Quantum Grid and I want to give the user the ability to move the columns and to rename the caption in the column header.  I used the OnColumnHeaderClick to open a dialog box for renaming the column.  Now the dialog box opens immediately when the mouse button is depressed so there is no opportunity to drag the header to move the column.  I don't see an event for a double click in the header which would be an easy solution.  
  Can someone suggest how I might give the user an intuitive, column-specific mouse action that would open an InputBox as the dialog for the new column header caption while preserving the ability to drag columns to create a new column order?

Thanks.
0
Comment
Question by:ttheimer
  • 2
4 Comments
 
LVL 26

Assisted Solution

by:Russell Libby
Russell Libby earned 75 total points
ID: 24056163

I have done a couple of feature rich apps using the Quantum Grid, and I know exactly what your talking about.

I offer the same rename capability (as well as a few other functions like hide column, auto-size, etc) and I ended up wiring up a popup menu that is fired on the right mb click on the column header. The user, if he choses the rename, is then shown a dialog with the current caption displayed and can change it at that point. Attempting to handle this directly in the left mb down is a bad idea IMHO, as it will interfere with the built in sorting and dragging.

Hth,
Russell
0
 

Author Comment

by:ttheimer
ID: 24056832
I would assume that you used the OnMouseDown event for the table view so how did you identify that you were on a header and to which column the header belonged?
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 175 total points
ID: 24057313
this is how to extend the quantumgrid rightclick menu

first thing: you need to add a TcxGridPopupMenu to the form
and assign the property Grid

next invoke the editor for the popupmenus and a new TcxPopupMenuInfo
and set it's properties:
The view it's for, when it will be visible you can set in the HitTypes property (your case: gvhtColumnHeader)
and then you add your own popupmenu

from your own popupmenu, you then can fire a inputbox to change the caption

that's the easy way, you could also extend the TcxGridTableCustomizationForm ... but that's more complex
procedure TForm1.OnPopColumnCaptionChangeClick(Sender: TObject);
var
  aColumnCaption: string;
  aView: TcxGridTableView;
begin
  aView := TableView1;
  aColumnCaption := aView.Controller.FocusedColumn.Caption;
  if InputQuery('Change column', 'Enter new title', aColumnCaption) then
    with aView.Controller do
    begin
      BeginUpdate;
      try
        FocusedColumn.Caption := aColumnCaption;
      finally
        EndUpdate;
      end;
    end;
end;

Open in new window

0
 

Author Comment

by:ttheimer
ID: 24059444
Geert_Gruwez:
  I followed your instructions and it all works!  The behavior that may have been disconcerting for the user is that a right-click on the header responds for the FocusedColumn and not the column that received the right click.  
   But "TcxGridColumnHeaderHitTest(AHitTest).Column" in he OnPopup event of the TcxGridPopupMenu object gives me the column receiving the right click so I was able to resolve this final issue.

Thanks for the help!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question