Skip to main content

SchedulerStorageBase.CreateResource(Object, String) Method

Creates a new resource with the specified ID and caption.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v25.1.Core.Desktop.dll

NuGet Package: DevExpress.Scheduler.CoreDesktop

Declaration

public Resource CreateResource(
    object resourceId,
    string resourceCaption
)

Parameters

Name Type Description
resourceId Object

The unique resource identifier.

resourceCaption String

The resource caption. This value is assigned to Resource.Caption property.

Returns

Type Description
Resource

A new resource.

Remarks

Use the CreateResource method to create a new resource.

void CreateSampleResource() {
    Resource res = schedulerControl1.Storage.CreateResource(0, "Resource1");
    schedulerStorage.Resources.Add(res);
    schedulerControl1.GroupType = SchedulerGroupType.Resource;
}

The CreateResource method:

  • Creates a new resource instance.
  • Automatically generates required custom fields and adds them to the resource’s CustomFieldCollection (available via the PersistentObject.CustomFields property).

To manually add custom fields to the resource, use the PersistentObjectStorage<T>.CreateCustomFields method.

Custom Resource Factory

The CreateResource method relies on a resource factory (an object that implements the IResourceFactory interface) to generate resources. To replace the default resource factory:

  1. Implement the IResourceFactory interface.
  2. Call the SchedulerStorageBase.SetResourceFactory method and pass your custom factory instance as a parameter.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateResource(Object, String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also