# GrapeCity.ActiveReports.Design.Designer.ResourceLocator

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Design_Designer_ResourceLocator_" data-uid="GrapeCity.ActiveReports.Design.Designer.ResourceLocator*">ResourceLocator Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Design_Designer_ResourceLocator_" data-uid="GrapeCity.ActiveReports.Design.Designer.ResourceLocator*"></a>
<h4 id="GrapeCity_ActiveReports_Design_Designer_ResourceLocator" data-uid="GrapeCity.ActiveReports.Design.Designer.ResourceLocator">ResourceLocator</h4>
<div class="markdown level1 summary"><p>Gets or sets a value representing the mechanism for locating and retrieving report resources such as images, data sources, and subreports.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public ResourceLocator ResourceLocator { get; set; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports.Core.Rdl/GrapeCity.ActiveReports.ResourceLocator.html">ResourceLocator</a></td>
      <td><p>An instance of <a class="xref" href="../MESCIUS.ActiveReports.Core.Rdl/GrapeCity.ActiveReports.ResourceLocator.html">ResourceLocator</a> that is responsible for locating and retrieving resources needed by the report. If not set, the designer
uses a default implementation.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Design_Designer_ResourceLocator_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>The <a class="xref" href="GrapeCity.ActiveReports.Design.Designer.ResourceLocator.html#GrapeCity_ActiveReports_Design_Designer_ResourceLocator">ResourceLocator</a> plays a critical role in the report generation process by enabling dynamic resolution of resources at design time and runtime.
This property allows for customization of the resource resolution process, which can be essential for applications that store report resources in non-standard
locations or need to apply custom logic to resource retrieval.</p>
<p>Setting this property to a custom implementation can provide greater flexibility and control over how resources are located and loaded, thereby 
accommodating complex application scenarios and resource management strategies.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Design_Designer_ResourceLocator_examples">Examples</h5>
<p>This property allows you to define a custom resource locator for accessing resources such as images and subreports from a specific location, whether
it's a custom storage solution or a particular directory on the disk. To utilize this feature, you must implement a custom resource locator.
See the example below for guidance on implementation:</p>
<pre><code class="lang-csharp">class MyResourceLocator : ResourceLocator
{
	public override Resource GetResource(ResourceInfo resourceInfo)
	{
		if (resourceInfo.Name == "redSquare.png")
		{
			//Here we draw the image with the red square in the center.
			//You can load the image from file system, or from data base, or from assembly resources.
			var img = new Bitmap(100, 100);
			using var graphics = Graphics.FromImage(img);
			using var redBrush = new SolidBrush(Color.Red);
			graphics.FillRectangle(redBrush, 10, 10, 80, 80);
			var tmpStream = new MemoryStream();
			img.Save(tmpStream, System.Drawing.Imaging.ImageFormat.Png);
			tmpStream.Position = 0;
			return new Resource(tmpStream, new Uri("redSquare.png", UriKind.Relative));
		}
		return new Resource();
	}
}</code></pre>
<p>Then, you can utilize this custom resource locator within the designer.</p>
<pre><code class="lang-csharp">class MyDesignerForm : Form
{
	public MyDesignerForm()
	{
		InitializeComponent();
		//note the designer must be added to the form and its name have to be '_designer'.
		_designer.ResourceLocator = new MyResourceLocator();
	}
}</code></pre>

</div>
