AnsweredAssumed Answered

Properties Reading & Editing Listbox

Question asked by Jean-Baptiste Bouckaert on Jul 15, 2016
Latest reply on Jul 18, 2016 by Mike Spens

Hi, currently I'm reading the custom properties from  a file and putting them in a ListBox. Propnames are the names of the properties and Propval are the values of these properties. I'm using VB.NET with the Document Manager API.


    Public Sub ReadWriteProps()


            propNames = dmDoc.GetCustomPropertyNames()


        If Not propNames Is Nothing Then


            For Each propName As String In propNames

                propVal = dmDoc.GetCustomProperty(propName, Nothing)

                clb_Properties.Items.Add(propName & ": " & propVal)


        End If


    End Sub


I have put a textbox beneath this and would like 2 things.

I'd like to display the value of the selected item in the listbox. Currently I use this code, but it gives me both the value and the name.


    Private Sub clb_Properties_SelectedIndexChanged(sender As Object, e As EventArgs) Handles clb_Properties.SelectedIndexChanged


        txt_PropertyEdit.Text = propVal(clb_Properties.SelectedItem)


    End Sub


Secondly, I'd like to click a button and then this would trigger the replacement of the value in the listbox of the selected item with the given value in the textbox.


    Private Sub btn_Edit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_Edit.Click


        propVal(clb_Properties.SelectedIndex) = txt_PropertyEdit.Text


    End Sub


This code however, gives me an error. I've also tried the 'SelectedItem' function. Does someone know how I fix this?