Hello,
How do you check that an owner exists in the OwnerCollection before you try to add a new one?
if (this._calendarInfo.Owners[ownerID] == null) { taskedOwner = this._calendarInfo.Owners.Add(ownerID); baseTask.Resources.Clear(); baseTask.Resources.Add(taskedOwner);
}
but it threw an exception on the first line about the key not being found.
I also tried the IndexOf() and GetItem() methods, but I got an index of 15 when the owner list was empty.
Sorry if this is a simple question, I'm a C++ programmer learning C# and I didn't see example where it traversed the owner collection before adding a new one.
Thanks,
Myca
I am glad you were able to address the issue on your own. Let us know if you have any additional questions about the UltraCalendarInfo or our schedule controls.
Nevermind, I got it. I just wasn't patient enough with what I had. Here's what worked:
index = this._calendarInfo.Owners.IndexOf(ownerID); if (index >= 0) { taskedOwner = (Owner)this._calendarInfo.Owners.GetItem(index); } else { taskedOwner = this._calendarInfo.Owners.Add(ownerID); } if (baseTask != null) { baseTask.Resources.Clear(); baseTask.Resources.Add(taskedOwner); }