We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Column selection within the GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

16321 Jul 12,2004 02:55 PM Jan 18,2005 10:01 AM Windows Forms 5
loading
Tags: GridControl
kstoj
Asked On July 12, 2004 02:55 PM

Within our DataBoundGrid we have a requirement to move the column to other location using mouse selection. I''m able to do that only after I set following properties on the grid: myGrid.Properties.RowHeaders = true; myGrid.ListBoxSelectionMode = System.Windows.Forms.SelectionMode.None; and of course: myGrid.AllowDragSelectedCols = true; Is this the only property combination which will allow me to select and move columns. With other settings to "ListBoxSelctionMode" property I''m simply unable to select columns and with the propert set to "None" I need to have "RowHeaders" unabled to be able to select Rows and Columns.

Administrator [Syncfusion]
Replied On July 13, 2004 01:13 AM

If you have ListBoxSelectionMode set to anything other than None, then this will prevent the default behavior from working. The reason is that only allowing row selections prevent columns from being selectable, and then you cannot drag a selected column. One work around that should work with any ListBoxSelectionMode setting is to also handle the CellClick. In the handler, explicitly select the column if you click a header. private void gridControl1_CellClick(object sender, GridCellClickEventArgs e) { //use this code to try to handle column selections with ListBoxSelectionMode set if(e.ColIndex > 0 && e.RowIndex == 0) { this.gridControl1.Selections.Add(GridRangeInfo.Col(e.ColIndex)); } } Working around not having a column header will require more coding. The reason is that the default behavior triggers on your user mousing down on the header of a selected column. Not having a header will precluce this from working (and also make it hader from your user to select the whole column). Here is a link to a forum thread that describes how you can drag a column without first selecting it. Now it uses the header cell to trigger the drag, but you could probably do it on dragging any cell. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9676

Charles Vereker
Replied On January 18, 2005 08:51 AM

I tried something similar - but on the row. // get the selected row & column int row = myGrid.CurrentCell.RowIndex; if (row<=1) return; // do nothing int col = gridIDDetailsList.CurrentCell.ColIndex; // highlight the whole row gridIDDetailsList.Selections.Add(GridRangeInfo.Row(row));

Charles Vereker
Replied On January 18, 2005 08:53 AM

(Please ignore previous message - slipped on keyboard) I tried something similar - but on the row. However it does not work. I did have it working, but things went pair shaped when I upgraded to v3.010 - I got a bit muddled!! What I observe when I click a cell is that the row is breifly highlighted, and then unhighlighted. Any ideas? Thanks Charlie // get the selected row & column int row = myGrid.CurrentCell.RowIndex; if (row<=1) return; // do nothing because of filter bar int col = myGrid.CurrentCell.ColIndex; // highlight the whole row myGrid.Selections.Add(GridRangeInfo.Row(row));

Administrator [Syncfusion]
Replied On January 18, 2005 09:07 AM

In your cellclick handler, try setting e.Cancel = true; so the grid does not continue with its click behavior that might be undoing what you have set. If this does not help, can you upload a sample showing the problem? I tried to see it in a simple GridControl dropped on a form, but could not.

Charles Vereker
Replied On January 18, 2005 10:01 AM

I was handling the control click event rather then the cellclick event! I did think it strange that I didn''t get given the clicked column/row numbers!! Thanks for your help. It works fine now. >In your cellclick handler, try setting e.Cancel = true; so the grid does not continue with its click behavior that might be undoing what you have set. > >If this does not help, can you upload a sample showing the problem? I tried to see it in a simple GridControl dropped on a form, but could not.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;