Question

I have a Ultragrid which has a column style as URL. This column in default is readonly which is grey in color. Now I have to make this column as editable. I tried like changing the column style when it is URL. But it doesn't work.

//Code:

If (CType(Field.FieldTypeId, ColumnStyle) = ColumnStyle.URL) Then
         UltraGridColumn.Style = ColumnStyle.Default
Else
         UltraGridColumn.Style = CType(Field.FieldTypeId, ColumnStyle)
End If

How can I achieve this?

Was it helpful?

Solution

To make an UltraGridColumn editable depends on numerous properities.

First and foremost, the UltraGrid should allow updating. This is controlled by the property

grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True

with this property you allow the entire grid to be updated (you can limit this applying the same property but at the Bands level). However this is not enough to enable editing because you need to set (for the individuals columns) two other properties

column.CellActivation = Activation.AllowEdit
column.CellClickAction = CellClickAction.Edit

However, I have made some research on the URL style. It seems that this style assigns to your columns a FormattedLinkEditor object that doesn't allow the link text to be edited in any way (It is considered a label). So I suggest, unless someone from Infragistics has a better recommendation, to use a normal edit column. (Of course, if your intention is only to edit the link text)

This short example captures the click on the cell and tries to start an editing session, but with no success

    private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        UltraGridColumn cc = e.Layout.Bands[0].Columns[0];
        cc.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.URL;
        (cc.Editor as FormattedLinkEditor).LinkClicked += Form1_LinkClicked;
        cc.CellActivation = Activation.AllowEdit;
        cc.CellClickAction = CellClickAction.EditAndSelectText;
        cc.Width = 500;
    }

    void Form1_LinkClicked(object sender, Infragistics.Win.FormattedLinkLabel.LinkClickedEventArgs e)
    {
        e.OpenLink = false;
        ultraGrid1.PerformAction(UltraGridAction.EnterEditMode);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top