I'm at my whits end with this one. I can not get this to work. I have a WinGrid (v2012.2). In two columns on each row I have an UltraFormattedTextEitor. Embedded in the editor is a single EditorButton in the LeftButtons group.
I want to be able to change the text and styling of the button at runtime depending on user behavior. I have the code, if you trace it, it shows the text value changing, but the display does not change.
A sample is below. Any help would be appreciated!!!
Imports Infragistics.WinImports Infragistics.Win.AppStylingImports Infragistics.Win.UltraWinGridImports Infragistics.Win.UltraWinEditorsImports Infragistics.Win.UltraWinDataSourceImports Infragistics.Win.FormattedLinkLabel
Public Class Form3 Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load Call InitializeWebGrid() Call AddRowToBand("Root", "Test Cell") End Sub Private Sub InitializeWebGrid() With UltraGrid1 Call .ResetDisplayLayout() Call .ResetLayouts() .DataSource = InitializeDataSource() With .DisplayLayout .UseFixedHeaders = False .Scrollbars = Scrollbars.Automatic .AutoFitStyle = AutoFitStyle.None With .Override .HeaderClickAction = HeaderClickAction.SortSingle .AllowColMoving = AllowColMoving.NotAllowed .AllowColSizing = AllowColSizing.None .AllowColSwapping = AllowColSwapping.NotAllowed .FixedRowIndicator = FixedRowIndicator.None .MergedCellStyle = MergedCellStyle.Never .RowSelectors = DefaultableBoolean.False .SelectTypeCell = SelectType.None .SelectTypeCol = SelectType.None .SelectTypeRow = SelectType.None .SupportDataErrorInfo = SupportDataErrorInfo.None .TipStyleScroll = TipStyle.Hide .RowSizing = RowSizing.Free End With End With End With End Sub Private Function InitializeDataSource() As UltraDataSource Dim strRoot As String = "Root" Dim objDataSource = New UltraDataSource With objDataSource Call .Reset() .Band.Key = strRoot End With Call FormatBand(objDataSource.GetBandByKey(strRoot)) Return objDataSource End Function Private Sub FormatBand(ByRef pobjDataBand As UltraDataBand) With pobjDataBand .AllowAdd = DefaultableBoolean.True .ReadOnly = DefaultableBoolean.False .Columns.Add("Column1", GetType(System.String)) End With End Sub Private Function AddRowToBand(ByVal pstrBand As String, ByVal pstrText As String) As UltraGridRow Dim objRow As UltraGridRow = UltraGrid1.DisplayLayout.Bands(pstrBand).AddNew() With objRow With .Band.Columns("Column1") .Width = 250 .CellActivation = Activation.AllowEdit .CellAppearance.TextHAlign = HAlign.Left .ButtonDisplayStyle = UltraWinGrid.ButtonDisplayStyle.Always End With
With .Cells("Column1") .CellDisplayStyle = CellDisplayStyle.FullEditorDisplay .Style = ColumnStyle.FormattedTextEditor .Activation = Activation.AllowEdit .EditorComponent = Initialize_UltraFormattedTextEditor() Call .SetValue(pstrText, False) End With End With Return objRow End Function Private Function Initialize_UltraFormattedTextEditor() As UltraFormattedTextEditor Dim objEditor As New UltraFormattedTextEditor With objEditor Call .ButtonsLeft.Clear() .ScrollBarDisplayStyle = UltraWinScrollBar.ScrollBarDisplayStyle.Never .ButtonsLeft.Add(Initialize_EditorButton) End With Return objEditor End Function Private Function Initialize_EditorButton() As EditorButton Dim objButton As New EditorButton With objButton .Text = "?" .Width = 18 .Enabled = True .Appearance.TextHAlign = HAlign.Center .Key = "Remove" End With Return objButton End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click CType(CType(UltraGrid1.Rows(0).Cells(0).EditorComponent, UltraFormattedTextEditor).ButtonsLeft(0), EditorButton).Text = "#" End SubEnd Class
Hello Jay,
I have logged a development issue for this.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing your active cases on the web site.
I've tried everything, changed every value. I'd like to be able to change the color of the buttons, foreground and background, as well as the text. I tried swapping to the UltraTextEditor, no luck.
I've tried turning off appstyling prior to changing the text or appearance, no luck.
The changes are being saved, you can see the desired values in the debugger, but they are not being displayed on the screen.
In my real program, here is the code where I am trying to change the properties at runtime.
Select Case .File.FlaggedForDeletionSW Case True .Editor.UseAppStyling = False .File.ValidSW = False .Cell.Activation = Activation.ActivateOnly .Button.Text = "N" .Button.Appearance.BackColor = Color.Red .Button.Appearance.ForeColor = Color.Black Case False .Editor.UseAppStyling = False .File.ValidSW = True .Cell.Activation = Activation.Disabled .Button.Text = "Y" .Button.Appearance.BackColor = Color.Green .Button.Appearance.ForeColor = Color.LightYellow End Select
.Editor: is the UltraTextEditor
.File: is the file I am working with
.Cell: is the cell which houses the Editor
.Button: is the button housed inside the LeftButtons collection of the UltraTextEditor control
The only way i have been able to change the appearance of the button in any way at runtime is by setting .cell.activation = disabled, and having a different appstyle for the disabled state. That does work, but nothing else...
Hi,
jnabors said:I'm at my whits end with this one.
Well... the good news is, it's not you. :)
I've tried everything I can think of to get the text to change and I can't get it to work, either. It looks like the UIElement must be caching the text and nothing I do seems to get it to update itself once it's stored. I even tried setting the EditorComponent on the cell to null and then back to the FormattedTextEditor and it still doesn't work.
I'm going to forward this over to Infragistics Developer Support and ask them to create a case for you and enter this as a bug for developer review so we can see what's going on here and get it fixed, or at least find you a reasonable workaround.