[]
        
(Showing Draft Content)

C1.Win.FlexGrid.C1FlexGridBase.ScrollBarAnnotationsUpdated

ScrollBarAnnotationsUpdated Event

Fires after the scrollbar annotations are updated.

Namespace: C1.Win.FlexGrid
Assembly: C1.Win.FlexGrid.10.dll
Syntax
public event EventHandler<ScrollBarAnnotationsUpdatedArgs> ScrollBarAnnotationsUpdated
Public Event ScrollBarAnnotationsUpdated As EventHandler(Of ScrollBarAnnotationsUpdatedArgs)
Returns
Type Description
EventHandler<ScrollBarAnnotationsUpdatedArgs> Fires after the scrollbar annotations are updated.
Remarks

You can update custom annotations when other annotation types are disabled by subscribing to this event then calling UpdateScrollBarAnnotations(bool, bool) method.

Examples

Custom annotations can be added to the list of all grid annotations in the event arguments ScrollBarAnnotationsUpdatedArgs.

public enum CustomAnnotationType
{
   Custom1,
   Custom2
}

public class CustomAnnotation : ScrollBarAnnotation
{
   public CustomAnnotationType Type { get; }
   public CustomAnnotation(CustomAnnotationType type, string text, double position, Color? color = null,
       HorizontalAlignment alignment = HorizontalAlignment.Center, int width = 100, int height = 2) :
       base(text, position, color, alignment, width, height)
   {
       Type = type;
   }
}

private void C1FlexGrid1_ScrollBarAnnotationsUpdated(object sender, ScrollBarAnnotationsUpdatedArgs e)
{
   ScrollBarAnnotation customAnnotation = e.Annotations.FirstOrDefault(x => x is CustomAnnotation ca && ca.Type == CustomAnnotationType.Custom1);
   var text = $"Custom annotation. Time: {DateTime.Now.ToLongTimeString()}";
   if (customAnnotation == null)
   {
       e.Annotations.Add(new CustomAnnotation(CustomAnnotationType.Custom1, text, 11, Color.Green, width: 70, height: 8));
       e.Annotations.Add(new CustomAnnotation(CustomAnnotationType.Custom2, text, 55, Color.YellowGreen, width: 70, height: -1));
   }
   else
   {
       customAnnotation.Text = text;
   }
}