none
Property which is not editable and can be changed with a UITypeEditor RRS feed

  • Question

  • Hey there.

    My code is like this. What I want is to have a property whose value is editable through a UITypeEditor (CurrencyEditor) only and isn't editable (Not read-only) right from propertygrid.

    <CategoryAttribute("Information"), DescriptionAttribute("")>
    <DefaultValue(GetType(Decimal), "0")>
    <DisplayName("Contract Price")>
    <Editor(GetType(CurrencyEditor), GetType(UITypeEditor))>
    <TypeConverter(GetType(CurrencyConverter))>
    Public Property ContractPrice() As Decimal

    Thanks.




    • Edited by samialtas Wednesday, June 12, 2019 7:57 PM
    Wednesday, June 12, 2019 7:29 PM

Answers

  • Thanks.

    I solved it with this code below.

    When a property named Budget's value is changed in propertygrid with a keystroke or cut/paste, it will assign its old value back while its value can be changed with a UITypeEditor (Dialog).

    Private Sub PropertyGrid1_PropertyValueChanged(s As Object, e As PropertyValueChangedEventArgs) Handles PropertyGrid1.PropertyValueChanged
    	Dim a As String = e.ChangedItem.PropertyDescriptor.Name
    	If a = "Budget" Then
    		e.ChangedItem.PropertyDescriptor.SetValue(PropertyGrid1.SelectedObject, e.OldValue)
    	End If
    End Sub





    • Marked as answer by samialtas Thursday, June 13, 2019 7:47 PM
    • Edited by samialtas Friday, June 14, 2019 7:22 AM
    Thursday, June 13, 2019 7:16 PM

All replies

  • Hello,

    See the following page, search for UiTypeEditor

    https://www.codeproject.com/Articles/28984/Rich-Design-Time-Editing-with-UITypeEditors-VB-NET


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, June 12, 2019 8:42 PM
    Moderator
  • Thanks.

    I solved it with this code below.

    When a property named Budget's value is changed in propertygrid with a keystroke or cut/paste, it will assign its old value back while its value can be changed with a UITypeEditor (Dialog).

    Private Sub PropertyGrid1_PropertyValueChanged(s As Object, e As PropertyValueChangedEventArgs) Handles PropertyGrid1.PropertyValueChanged
    	Dim a As String = e.ChangedItem.PropertyDescriptor.Name
    	If a = "Budget" Then
    		e.ChangedItem.PropertyDescriptor.SetValue(PropertyGrid1.SelectedObject, e.OldValue)
    	End If
    End Sub





    • Marked as answer by samialtas Thursday, June 13, 2019 7:47 PM
    • Edited by samialtas Friday, June 14, 2019 7:22 AM
    Thursday, June 13, 2019 7:16 PM