Back to Devexpress

SchedulerDataStorage.CreateResource(Object, String) Method

windowsforms-devexpress-dot-xtrascheduler-dot-schedulerdatastorage-dot-createresource-x28-system-dot-object-system-dot-string-x29.md

latest5.0 KB
Original Source

SchedulerDataStorage.CreateResource(Object, String) Method

Creates a new resource with the specified ID and a caption.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public Resource CreateResource(
    object resourceId,
    string resourceCaption
)
vb
Public Function CreateResource(
    resourceId As Object,
    resourceCaption As String
) As Resource

Parameters

NameTypeDescription
resourceIdObject

An object that is the unique resource identifier.

| | resourceCaption | String |

A string that is the resource caption accessible using the Resource.Caption property.

|

Returns

TypeDescription
Resource

A Resource object.

|

Remarks

Use the CreateResource method to create a new resource. This method also creates all the required custom fields, and adds them to the resource’s CustomFieldCollection , available via the PersistentObject.CustomFields property. To add custom fields to the resource manually, use the PersistentObjectStorage<T>.CreateCustomFields method.

csharp
Resource resource = schedulerDataStorage.CreateResource(0, "TestResource"); 
schedulerDataStorage.Resources.Add(resource); 
apt.ResourceId = resource.Id
vb
Dim resource As Resource = schedulerStorage.CreateResource(0, "TestResource") 
schedulerStorage.Resources.Add(resource) 
apt.ResourceId = resource.Id

The following code snippets (auto-collected from DevExpress Examples) contain references 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.

winforms-scheduler-sync-with-outlook/CS/SyncWithOutlook/Form1.cs#L206

csharp
{
    Resource res = schedulerStorage1.CreateResource(i, String.Format("Resource {0}", i));
    schedulerStorage1.Resources.Add(res);

winforms-scheduler-formatting-services/CS/FormattingServicesExample/Data/Data.cs#L24

csharp
for(int i = 1; i <= cnt; i++)
    resources.Add(storage.CreateResource(i, Users[i - 1]));

winforms-scheduler-custom-draw-appointments/CS/CustomDrawDemo/Form1.cs#L56

csharp
for(int i = 1; i <= cnt; i++)
        storage.Resources.Items.Add(storage.CreateResource(Guid.NewGuid(), Users[i - 1]));
}

winforms-scheduler-formatting-services/VB/FormattingServicesExample/Data/Data.vb#L21

vb
For i As Integer = 1 To cnt
    resources.Add(storage.CreateResource(i, Users(i - 1)))
Next

winforms-scheduler-custom-draw-appointments/VB/CustomDrawDemo/Form1.vb#L54

vb
For i As Integer = 1 To cnt
    storage.Resources.Items.Add(storage.CreateResource(Guid.NewGuid(), Users(i - 1)))
Next i

See Also

SchedulerDataStorage Class

SchedulerDataStorage Members

DevExpress.XtraScheduler Namespace