This is a migrated thread and some comments may be shown as answers.

Digit number on PropertyGridSpinEditor

0 Answers 9 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
MaiK
Top achievements
Rank 1
MaiK asked on 17 Sep 2018, 11:07 AM

Hi,

 

I need a PropertyGridSpinEditor with a small difference, it must always show 2 digit. Example: "00", "03", "14"..

You can see in the image, i have achieved only when the edition has ended with this code.

Private Sub PropertyGridParams_ItemFormatting(sender As Object, e As UI.PropertyGridItemFormattingEventArgs) Handles PropertyGridParams.ItemFormatting
       
     If (e.Item.Name = NameOf(PROPNAME)) Then
         DirectCast(e.VisualElement, PropertyGridItemElement).ValueElement.Text = PROP.ToString("00")
      End If
End Sub

 

I try it, but doesnt work.

Public Class NumericUpDownEditor
    Inherits PropertyGridSpinEditor
 
 
    Public Overrides Sub OnValueChanged()
 
        If (Me.Value.ToString.Length < 2 AndAlso IsNumeric(Me.Value)) Then
 
            Me.Value = Integer.Parse(Me.Value.ToString()).ToString("00")
        Else
            MyBase.OnValueChanged()
        End If
 
    End Sub
 
 
End Class

 

Is there any way to achieve that?

 

Thank you!

No answers yet. Maybe you can help?

Tags
PropertyGrid
Asked by
MaiK
Top achievements
Rank 1
Share this question
or