UltraGrid event ClickCell is disabled when changing stylo

I have a function that expands and retracts the lines of an ultragrid as the click on a cell. I am using the following code:

columnUltraGrid.CellMultiLine = Infragistics.Win.DefaultableBoolean.True;
columnUltraGrid.Layout.Override.RowSizing = RowSizing.AutoFree;
columnUltraGrid.Layout.Override.RowSizingAutoMaxLines = 4;
columnUltraGrid.Layout.Bands[0].AutoPreviewEnabled = true;

From the moment that I add this code:

columnUltraGrid.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText; 
columnUltraGrid.CellDisplayStyle = Infragistics.Win.UltraWinGrid.CellDisplayStyle.FormattedText;

The cell in question stops calling the ClickCell event. The cell in question stops calling the clickcell event, I need to use this command to remove the html formatting contained in the text, I did not find another way, if someone can inform me otherwise to format the text or enable the event call I thank. The contents of the cell is an html such as: <'span style='font-weight:bold;'>hello

Upvotes: 1

Views: 632

Answers (1)

wnvko
wnvko

Reputation: 2120

I do not think your issue is related to the Style of the column, neither to the Style of the cell. The first time you click in the cell, by default it enters in edit mode. At this moment a TextBox is drawn over the cell, allowing end users to edit the cell's data. If you click again on the cell you are actually clicking on this TextBox and it eats the click event. You can overcome this in two ways:

  1. If you are not allowing your users to edit the cell text set CellClickAction to CellSelect or RowSelect, whatever is better for your scenario;
  2. If you are allowing end users to edit the cell's text then you will need to handle the Click event of the TextBox the guys at Infragistics use. To do so handle the ControlAdded event of your grid. The first time any cell of the grid enters in edit mode TextBox control gets added to the grid's Controls collection. Then the same TextBox is used for any cell in edit mode.

You can do something like this:

private void UltraGrid1_ControlAdded(System.Object sender, System.Windows.Forms.ControlEventArgs e)
{
    e.Control.Click += UltraGrid1_Editor_Click;
}

Do not forget to subscribe off when, for any reason, TextBox is removed from the grid:

private void UltraGrid1_ControlRemoved(System.Object sender, System.Windows.Forms.ControlEventArgs e)
{
    e.Control.Click -= UltraGrid1_Editor_Click;
}

Upvotes: 1

Related Questions