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. Image for the cookie policy date
close icon

GridGroupingControl - Focus changes to first column on start up

I use GridGroupingControl, and have this control displayed in a Window that doesn''t show the whole grid. When I first load my application and click on a CheckBox column the first record column appears selected, and within TableControlCheckBoxClick when I do:

GridCurrentCell cc = _dataGrid.TableControl.CurrentCell;

the cc.ColIndex refers to the first data column rather than to the column I actually clicked on.

The same happens when I click on a ComboBox column which isn''t initially shown to the window (i.e. havwe to scroll right to view and then click). With a ComboBox that is initially viewable this doesn''t occur.

Any ideas?

I''m using 4.2.0.37

8 Replies

AD Administrator Syncfusion Team August 8, 2006 10:45 AM UTC

Hi Vito,

You can use this code snippet to get the colIndex of the checkbox column when the checkbox is clicked.

private void grid_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
Console.WriteLine("CheckBox Column Index:" + e.Inner.ColIndex);
}

//For ComboBox cell column Index when the Button is clicked

private void grid_TableControlCellButtonClicked(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellButtonClickedEventArgs e)
{
Console.WriteLine( "combo column Index:" + e.Inner.ColIndex);
}

Let me know if this helps.
Thanks
Haneef




CH Clive Hill August 8, 2006 12:24 PM UTC

It seems from what you say that I should avoid using TableControl.CurrentCell as this might not be set to the actual CurrentCell. In one of the ComboBox columns I need to get the Renderer as GridComboBoxCellRenderer so that I can do:

cr.ListBoxPart.SelectedItem

I was getting the Renderer from GridCurrentCell, by cc.Renderer, but if this isn''t safe, can you recommend a way to get this from parameters of TableControlCurrentCellCloseDropDown, i.e.

GridTableControlPopupClosedEventArgs
and
GridGroupingControl


AD Administrator Syncfusion Team August 9, 2006 11:27 AM UTC

Hi Vito,

If you set the property ActivateCurrentCellBehavior to ClickOnCell then the cell gets activated after clicking on it. To move the current cell in checkbox click/cellclick event , you need to use the CurrentCell.MoveTo method.

e.TableControl.CurrentCell.MoveTo(e.Inner.RowIndex,e.Inner.ColIndex);

To get the currentcell renderer, you can use the e.TableControl.CurrentCell.Renderer property.

To get the particular cell renderer, you can use the GetCellRenderer method in Tablecontrol. Please find the code snippet below.

//For CheckBox click event.
e.TableControl.GetCellRenderer(e.Inner.RowIndex,e.Inner.ColIndex);

Thanks,
Haneef


CH Clive Hill August 9, 2006 05:38 PM UTC

Thanks Haneef. Can you tell me where ActivateCurrentCellBehavior property is for a GridGroupingControl grid? I had a look through properties of various objects under GGC and can''t find this.


AD Administrator Syncfusion Team August 10, 2006 04:15 AM UTC

Hi Vito,

Please find the ActivateCurrentCellBehavior property from TableModel.Options. Here is a code snippet.

//Default setting is ClickOnCell.
this.grid.TableModel.Options.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell;

Thanks,
Haneef


CH Clive Hill August 10, 2006 07:55 AM UTC

That seems to have worked - thanks Haneef


CH Clive Hill August 10, 2006 03:13 PM UTC

Haneef,

The problem is fixed in every scenario I''ve tested except:

on start up of application, if a column with ComboBox is initially out of view, the user scrolls horizontally until it is in view and then clicks to change value.

When this occurs GridTableCellStyleInfoIdentity does not seem to be correctly inialized. I obtain this by:

GridTableCellStyleInfoIdentity style = _dataGrid.TableModel[comboBoxRowIndex, comboBoxColIndex].TableCellIdentity;

style doesn''t have DisplayElement.ParentRecord or Column defined.

I can get a reference to the current record doing:

rec = (Syncfusion.Grouping.Record)e.TableControl.Table.CurrentRecord;

instead, is there a way to get reference to the current column mapping name, without using style.Column.Name ?

I tried doing:


GridColumnDescriptor gcd = e.TableControl.Table.GetColumnDescriptorAt(comboBoxRowIndex, comboBoxColIndex);

but gcd is undefined.


AD Administrator Syncfusion Team August 14, 2006 08:39 AM UTC

Hi Vito,

Please try the attached sample that works fine on my system which has "Essential Studio 4.2 +.Net FrameWork 1.1/2.0+windows XP" installed . Let us know if you face any other issues.

Here is a sample
http://www.syncfusion.com/Support/user/uploads/CaptionPluasMinus_6c591ff8.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon