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

Behaviour of EllipsisCell with ShowCurrentCell

Hi,

I modified the CustomCellTypes\CellButtons Sample in EllipsisCell.cs:

public override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
// Here you can adjust settings that override the default settings from the grid
e.Style.ShowButtons = GridShowButtons.ShowCurrentCell;
e.Style.Clickable = true;
e.Style.TextAlign = GridTextAlign.Left;
e.Style.VerticalAlignment = GridVerticalAlignment.Middle;
e.Style.WrapText = false;
}

The buttons are shown correctly only when I enter the cell. But when a user tries to select the (unselected) cell in the area where the button is drawn later with the mouse, he selects the (not visible) button.

Is there a possibility to avoid this?

Regards,
Christian

4 Replies

HA haneefm Syncfusion Team April 4, 2007 05:58 PM UTC

Hi Christian,

If you want to control the showing of the cell button in a grid then you can handle the DrawCellButton event and use e.Button.DrawButton to draw the button in a cell. Here is a code snippet.

private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
// Here you can adjust settings that override the default settings from the grid
//e.Style.ShowButtons = GridShowButtons.ShowCurrentRow;
e.Style.Clickable = true;
e.Style.TextAlign = GridTextAlign.Left;
e.Style.VerticalAlignment = GridVerticalAlignment.Middle;
e.Style.WrapText = false;
}

private void gridControl1_DrawCellButton(object sender, GridDrawCellButtonEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if((cc.RowIndex == e.RowIndex && cc.ColIndex == e.ColIndex ) //For CurrentCell
|| grid.Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Cell(e.RowIndex,e.ColIndex) )) // For Selected Range
{
e.Button.DrawButton(e.Graphics,e.Button.Bounds,ButtonState.Normal,e.Style);
e.Cancel = true;
}
else
e.Cancel = true;
}

Best regards,
Haneef


CL Christian Lützenkirchen April 13, 2007 08:59 AM UTC

Hi Haneef,

thank you for your sample but it seems to be a misunderstanding. My problem is not the drawing of a button. It works fine when I change
e.Style.ShowButtons = GridShowButtons.ShowCurrentCell;
in ElipsisCell.cs.

The problem is the click into a cell. Please modify the line in OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e) of ElipsisCell.cs an run the sample. The buttons in the cell "Browse Me" are not shown. Now try to select the cell. If you select the cell near the left border, it changes to edit mode and the button is shown. Correct! But if you just want to add text behind the "Browse Me"-text and click near the right border of the cell to position the cursor there (remind: the button is not shown to the user!) you click the invisible button. But your intention is not to click the button but to position the cursor!

How can I modify the ElipsisCell-class that a click near the right border switches the cell to edit mode and then shows the button and not causes the click event to fire. If the button is shown, the click event has to fire!

Best Regards,
Christian


CL Christian Lützenkirchen April 25, 2007 05:34 PM UTC

Hi Haneef,

any suggestions?

Regards,
Christian


RA Rajagopal Syncfusion Team April 25, 2007 10:08 PM UTC

Hi Christian,

Sorry for the delay in getting back to you. Thanks for your patience.

Please make the following changes to the CellButtonClicked event in Form1.cs of the CellButtons sample, to control the CellButtonClicked event to fire only when the button is shown for the currentcell.

private void gridControl1_CellButtonClicked(object sender, GridCellButtonClickedEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridRangeInfo rg = GridRangeInfo.Cell(e.RowIndex, e.ColIndex);
if (e.ColIndex == 5 && cc.HasCurrentCellAt( e.RowIndex, e.ColIndex ))
{
MessageBox.Show( "Clicked button at " + rg.ToString() );
}
else
e.Cancel = true;
}

Let us know if this helps.
Regards,
Rajagopal


Loader.
Live Chat Icon For mobile
Up arrow icon