[CONNECT C#] How to apply pick lists to other data types than strings

I sucessfully managed to create and apply PickLists to the properties in my Item Types. Really useful!

My problem is that PickList values are strings and I get a data converison error if I try to use the PickList on anything else than string properties. Perhaps I should use the 

PickListValueChangedEventHandler but I cannot figure out how this is done. The documentation is as always quite limited.
Regards,
Krister
  • Try to adding event interest like:

    PickListHandler.PickListValueChanged += OnPickListValueChanged;

    And event handler like to inspect or refresh the control if needed:

    private void OnPickListValueChanged(object sender)
        {
        bool modified = false;
        ...
        modified = PickListHandler.ModifyInstance(instance);
        ...
        if (modified)
           //e.g. RefreshControl_IfNeeded();
        }

    HTH,
    Bob



  • Can anyone tell me what PickList is doing in MicroStation?

  • Can anyone tell me what PickList is doing in MicroStation?

    Search the MicroStation CONNECT Update 7 documentation (not the API documentation) carefully, where Picklists are mentioned a couple of times in conjunction with Item Types.  They enable an admin. to specify a list of values that can be applied to an Item Type instance. 

    I believe that they may be the answer to this idea.  More may be revealed in Update 8.

     
    Regards, Jon Summers
    LA Solutions

  • Thanks for your answer.

    I can, however, not get the event handler to activate. Maybe I miss something. The attached code will create the PickLists and save them to the file (this works). I tried to add your code to registrer the handler but it is not called. I also added a call to RegistrerHandler() without knowing if it's needed or not. Trial and error!

    If I can get the handler to active I will need to figure out what to do inside the handler. What I want to do is to get the new value and try to cast the string value to the attributes data type (CustomProperty.TypeKind). Feel free to give me some help!

            public override void SavePickLists(Map map)
            {
                BDPN.PickListHandler.DeletePickListLibFromDgn(DgnHelper.GetActiveDesignFile());
    
                BDPN.PickListLibrary pickListLibrary = BDPN.PickListLibrary.Create();
    
                uint n = 0;
    
                foreach (AttributePickList pickList in map.PickLists)
                {
                    if (pickList.Count > 0)
                    {
                        BDPN.PickList dgnPickList = pickListLibrary.AddPickList(pickList.Name, n++, DgnHelper.GetActiveDesignFile());
    
                        foreach (AttributePickListItem item in pickList)
                        {
                            dgnPickList.AddValue(item.Value, item.Id);
                        }
                    }
                }
                
                BDPN.PickListHandler.PickListValueChanged += OnPickListValueChanged;
    
                // Is this needed?
                BDPN.PickListHandler.RegisterHandler();
    
                BDPN.PickListHandler.SavePickListLibToDgn(DgnHelper.GetActiveDesignFile(), pickListLibrary, false);
            }
    
            private void OnPickListValueChanged(object sender)
            {
                bool modified = false;
            
                //modified = BDPN.PickListHandler.ModifyInstance(instance);
            
                if (modified)
                {
                    //e.g. RefreshControl_IfNeeded();
                }
            }

    Owner consultant at Surell Consulting AB

  • NOTE:

    PickList APIs are currently a feature in Tech Preview (prior to being a "released feature") and until fully published as a released feature should be considered a work in progress.  It is unfortunately that we have had to temporarily remove the PickList APIs, though once stabilized *should* become available again soon.  Additional type support is being considered; like Integer and Numeric types; though these may become available a bit further out.  We are certainly glad to see your early adoption and excitement over this new feature area of the APIs and we hope to make this available again for you very soon. 

    Bob