Solved

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

Posted on 2009-04-02
4
1,156 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now