API: ComboBox with Workobjects

Hello

I have made a ComboBox that I fill with all workobjects that are in the active task but i would like to refill it when the user adds a new workobject to the task.

//Get all workobjects
cbParentWobj.Items.Clear();
cbDispWobj.Items.Clear();

foreach (RsDataDeclaration rsdd in stn.ActiveTask.DataDeclarations)
{
if (rsdd.DataType == “wobjdata”)
{
cbParentWobj.Items.Add(new CommandBarComboBoxItem(rsdd.Name));
cbDispWobj.Items.Add(new CommandBarComboBoxItem(rsdd.Name));

//Select the active workobject
if (rsdd.Name == stn.ActiveTask.ActiveWorkObject.Name)
{
cbParentWobj.SelectedIndex = cbParentWobj.Items.Count - 1;
cbDispWobj.SelectedIndex = cbDispWobj.Items.Count - 1;
}
}
}

Are there any good events that I can use that fires when a new data declaration is made?

Or are there any ready data collections with all workobjects that will be updated?

There are a similar combobox under home and settings. I would like the same function as that one.

Hi Patrik,

I would recommend using the ComboBox.DropDown event to re-fill the combo when the user clicks it. That way you don’t have to depend on RS events to keep the contents in sync.

regards,
Johannes

Perfect I will try that tomorrow..

I used the DropDown event and it works good for my scope of use..

Thanks