### Run Application and Get Process
Source: https://github.com/telerik/winforms-docs.git/blob/master/testing/test-complete/create-a-test-manually/write-a-test-script.md
Initializes the test by running the Telerik Examples application and obtaining a process variable for further interaction.
```C#
//USEUNIT HelpFunctions
function RadGridViewExcelLikeFilteringTest()
{
RunApplicationTelerikExamples()
process = Sys["Process"]("TelerikExamples")
}
```
--------------------------------
### Manually Start Webcam
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/webcam/getting-started.md
Initiate the webcam stream by calling the Start method after the control has been initialized.
```C#
radWebCam1.Start();
```
```VB.NET
radWebCam1.Start()
```
--------------------------------
### VB.NET Example: Setting up CheckedDropDownList AutoComplete
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/custom-items-in-checkeddropdownlist-autocomplete-popup.md
This VB.NET code snippet shows the initial setup for a RadCheckedDropDownList, including data binding and event subscription for customizing visual items. It's a starting point for implementing custom checkboxes in the autocomplete popup.
```VB.NET
Shared checkedItems As List(Of String) = New List(Of String)()
Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
Me.RadCheckedDropDownList1.DisplayMember = "ProductName"
Me.RadCheckedDropDownList1.DataSource = Me.ProductsBindingSource
Me.RadCheckedDropDownList1.AutoCompleteMode = AutoCompleteMode.Suggest
AddHandler Me.RadCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.ListElement.CreatingVisualItem, _
AddressOf ListElement_CreatingVisualItem
```
--------------------------------
### Initialize DocumentClient and create database
Source: https://github.com/telerik/winforms-docs.git/blob/master/cloud-integration/azure/connect-to-data-in-the-cloud/cosmos-db.md
Instantiate the DocumentClient with your endpoint URL and primary key, and then create the 'EmployeeDB' database if it doesn't already exist. Note that creating a collection has pricing implications.
```csharp
this.client = new DocumentClient(new Uri(EndpointUrl), PrimaryKey);
this.client.CreateDatabaseIfNotExistsAsync(new Database { Id = "EmployeeDB" });
```
```vbnet
Me.client = New DocumentClient(New Uri(EndpointUrl), PrimaryKey)
Me.client.CreateDatabaseIfNotExistsAsync(New Database With {.Id = "EmployeeDB"})
```
--------------------------------
### Initial Setup for Hlc Series
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/series-types/hlc.md
Demonstrates how to create and populate an HlcSeries with data points. Use this for initializing the Hlc series with high, low, close values and a date.
```C#
HlcSeries hlcSeries = new HlcSeries();
hlcSeries.DataPoints.Add(new HlcDataPoint(11, 7, 8, DateTime.Now));
hlcSeries.DataPoints.Add(new HlcDataPoint(9, 5, 9, DateTime.Now.AddDays(1)));
hlcSeries.DataPoints.Add(new HlcDataPoint(12, 9, 10, DateTime.Now.AddDays(2)));
hlcSeries.DataPoints.Add(new HlcDataPoint(10, 6, 9, DateTime.Now.AddDays(3)));
this.radChartView1.Series.Add(hlcSeries);
```
```VB.NET
Dim hlcSeries As New HlcSeries()
hlcSeries.DataPoints.Add(New HlcDataPoint(11, 7, 8, DateTime.Now))
hlcSeries.DataPoints.Add(New HlcDataPoint(9, 5, 9, DateTime.Now.AddDays(1)))
hlcSeries.DataPoints.Add(New HlcDataPoint(12, 9, 10, DateTime.Now.AddDays(2)))
hlcSeries.DataPoints.Add(New HlcDataPoint(10, 6, 9, DateTime.Now.AddDays(3)))
Me.RadChartView1.Series.Add(hlcSeries)
```
--------------------------------
### Get Appointment Start Time
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/scheduler/dialogs/editappointmentdialog.md
Retrieves the start date and time for an appointment, considering whether it is an all-day event.
```vb
Private Function GetAppointmentStart() As DateTime
Dim startDate As DateTime = Me.dateStart.Value.[Date]
If Not (Me.appointment.AllDay) Then
Dim startTime As TimeSpan = Me.timeStart.Value.Value.TimeOfDay
startDate = startDate.Add(startTime)
End If
Return startDate
End Function
```
--------------------------------
### Starting Edit Programmatically
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/listview/editors/editors.md
This example demonstrates how to programmatically start the editing process for a selected item in RadListView using C# and VB.NET.
```APIDOC
## Starting Edit Programmatically
### Description
Initiates editing on the selected item in RadListView.
### Method
`BeginEdit()`
### Parameters
None
### Request Example
```C#
radListView1.AllowEdit = true;
radListView1.SelectedItem = radListView1.Items[0];
radListView1.CurrentColumn = radListView1.Columns[0]; // For DetailsView
radListView1.BeginEdit();
```
```VB.NET
RadListView1.AllowEdit = True
RadListView1.SelectedItem = RadListView1.Items(0)
RadListView1.CurrentColumn = RadListView1.Columns(0) ' For DetailsView
RadListView1.BeginEdit()
```
```
--------------------------------
### Basic AutocompleteList Setup
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/autocompletelist-with-dynamic-datasource.md
This snippet shows the basic structure for setting up an AutocompleteList. It demonstrates how to define a class and a method to return a new expression.
```vbnet
Public Class MyClass
Public Function NewExpression() As Object
Return NewObject()
End Function
End Class
```
--------------------------------
### Usage Example (VB.NET)
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/create-standalone-radexpressioneditor-form.md
Demonstrates how to instantiate the standalone form, show it with an initial value, and retrieve the result. This requires only a few lines of code.
```vbnet
Dim form As New StandaloneExpressionEditorForm()
If form.ShowDialog(Me.RadTextBox1.Text) = System.Windows.Forms.DialogResult.OK Then
Me.RadTextBox2.Text = form.ReturnValue
End If
```
--------------------------------
### Get Appointment Start Time
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/scheduler/dialogs/editappointmentdialog.md
This C# method retrieves the start date and time for an appointment. It accounts for whether the appointment is an all-day event.
```csharp
private DateTime GetAppointmentStart()
{
DateTime startDate = this.dateStart.Value.Date;
if (!(this.appointment.AllDay))
{
TimeSpan startTime = this.timeStart.Value.Value.TimeOfDay;
startDate = startDate.Add(startTime);
}
return startDate;
}
```
--------------------------------
### Initial Setup OhlcSeries
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/series-types/ohlc-and-candlestick.md
Use this snippet to initialize and populate an OhlcSeries with data points. Each data point requires open, high, low, close values, and a date.
```csharp
OhlcSeries ohlcSeries = new OhlcSeries();
ohlcSeries.DataPoints.Add(new OhlcDataPoint(10, 11, 7, 8, DateTime.Now));
ohlcSeries.DataPoints.Add(new OhlcDataPoint(8, 9, 5, 9, DateTime.Now.AddDays(1)));
ohlcSeries.DataPoints.Add(new OhlcDataPoint(12, 12, 9, 10, DateTime.Now.AddDays(2)));
ohlcSeries.DataPoints.Add(new OhlcDataPoint(7, 10, 6, 9, DateTime.Now.AddDays(3)));
this.radChartView1.Series.Add(ohlcSeries);
```
```vbnet
Dim ohlcSeries As New OhlcSeries()
ohlcSeries.DataPoints.Add(New OhlcDataPoint(10, 11, 7, 8, DateTime.Now))
ohlcSeries.DataPoints.Add(New OhlcDataPoint(8, 9, 5, 9, DateTime.Now.AddDays(1)))
ohlcSeries.DataPoints.Add(New OhlcDataPoint(12, 12, 9, 10, DateTime.Now.AddDays(2)))
ohlcSeries.DataPoints.Add(New OhlcDataPoint(7, 10, 6, 9, DateTime.Now.AddDays(3)))
Me.RadChartView1.Series.Add(ohlcSeries);
```
--------------------------------
### Workspace-Specific MCP Server Setup
Source: https://github.com/telerik/winforms-docs.git/blob/master/ai-coding-assistant/mcp-server.md
Configure the MCP server for a specific project by adding a .mcp.json file to your solution folder. This setup uses 'npx' to install the latest version of the assistant.
```json
{
"inputs": [],
"servers": {
"telerik-winforms-assistant": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@progress/telerik-winforms-mcp@latest"],
"env": {
"TELERIK_LICENSE_PATH": "THE_PATH_TO_YOUR_LICENSE_FILE",
"TELERIK_LICENSE": "YOUR_LICENSE_KEY"
}
}
}
}
```
--------------------------------
### AppointmentsComparer
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/scheduler/properties-methods-events.md
Gets or sets a comparer used to determine the order of appointments with the same start and end dates.
```APIDOC
## Property: AppointmentsComparer
### Description
Gets or sets a comparer which will be used to determine the order of the appointments when they have the same Start and End dates.
### Type
Comparer
```
--------------------------------
### VB.NET: Setup GanttView Data Items and Links
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/ganttview/custom-items/data-items.md
This code demonstrates how to set up GanttView data items, including summary tasks and sub-tasks, and define various types of links between them. It also shows how to configure the GanttView columns and handle editor initialization events.
```vbnet
item2.Start = New DateTime(2010, 10, 12)
item2.[End] = New DateTime(2010, 10, 18)
item2.Progress = 40D
item2.Title = "Summary task.2. title"
Dim subitem21 As MyGanttViewDataItem = New MyGanttViewDataItem()
subitem21.Start = New DateTime(2010, 10, 12)
subitem21.[End] = New DateTime(2010, 10, 13)
subitem21.Progress = 10D
subitem21.Title = "Sub-task.2.1 title"
Dim subitem22 As MyGanttViewDataItem = New MyGanttViewDataItem()
subitem22.Start = New DateTime(2010, 10, 13)
subitem22.[End] = New DateTime(2010, 10, 18)
subitem22.Progress = 30D
subitem22.Title = "Sub-task.2.2 title"
Dim subitem23 As MyGanttViewDataItem = New MyGanttViewDataItem()
subitem23.Start = New DateTime(2010, 10, 18)
subitem23.[End] = New DateTime(2010, 10, 18)
subitem23.Title = "Sub-task.2.3 title"
item2.Items.Add(subitem21)
item2.Items.Add(subitem22)
item2.Items.Add(subitem23)
Me.radGanttView1.Items.Add(item2)
Dim link1 As GanttViewLinkDataItem = New GanttViewLinkDataItem()
link1.StartItem = subitem11
link1.EndItem = subitem12
link1.LinkType = TasksLinkType.FinishToStart
Me.radGanttView1.Links.Add(link1)
Dim link2 As GanttViewLinkDataItem = New GanttViewLinkDataItem()
link2.StartItem = subitem21
link2.EndItem = subitem22
link2.LinkType = TasksLinkType.StartToStart
Me.radGanttView1.Links.Add(link2)
Dim link3 As GanttViewLinkDataItem = New GanttViewLinkDataItem()
link3.StartItem = subitem22
link3.EndItem = subitem23
link3.LinkType = TasksLinkType.FinishToStart
Me.radGanttView1.Links.Add(link3)
Dim titleColumn As GanttViewTextViewColumn = New GanttViewTextViewColumn("Title")
Dim startColumn As GanttViewTextViewColumn = New GanttViewTextViewColumn("Start")
Dim endColumn As GanttViewTextViewColumn = New GanttViewTextViewColumn("End")
Dim durationColumn As GanttViewTextViewColumn = New GanttViewTextViewColumn("Duration")
Me.radGanttView1.GanttViewElement.Columns.Add(titleColumn)
Me.radGanttView1.GanttViewElement.Columns.Add(startColumn)
Me.radGanttView1.GanttViewElement.Columns.Add(endColumn)
Me.radGanttView1.GanttViewElement.Columns.Add(durationColumn)
AddHandler Me.radGanttView1.GanttViewElement.EditorInitialized, AddressOf GanttViewElement_EditorInitialized
```
--------------------------------
### Create Multiple ToolWindows and DocumentWindows at Runtime
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/dock/object-model/creating-toolwindow-and-documentwindow-at-runtime.md
This example demonstrates creating and arranging multiple ToolWindows and DocumentWindows programmatically. It shows docking ToolWindows to specific positions and adding multiple documents to the RadDock control.
```C#
ToolWindow windowLeft = new ToolWindow();
windowLeft.Text = "Window Left";
this.radDock1.DockWindow(windowLeft, DockPosition.Left);
ToolWindow windowBottom = new ToolWindow();
windowBottom.Text = "Window Bottom";
this.radDock1.DockWindow(windowBottom, DockPosition.Bottom);
ToolWindow windowBottomRight = new ToolWindow();
windowBottomRight.Text = "Window Bottom Right";
this.radDock1.DockWindow(windowBottomRight, windowBottom, DockPosition.Right);
DocumentWindow document1 = new DocumentWindow();
document1.Text = "Document 1";
this.radDock1.AddDocument(document1);
DocumentWindow document2 = new DocumentWindow();
document2.Text = "Document 2";
this.radDock1.AddDocument(document2);
DocumentWindow document3 = new DocumentWindow();
document3.Text = "Document 3";
this.radDock1.AddDocument(document3);
```
```VB.NET
Dim windowLeft As ToolWindow = New ToolWindow()
windowLeft.Text = "Window Left"
Me.RadDock1.DockWindow(windowLeft, DockPosition.Top)
Dim windowBottom As ToolWindow = New ToolWindow()
windowBottom.Text = "Window Bottom"
Me.RadDock1.DockWindow(windowBottom, DockPosition.Bottom)
Dim windowBottomRight As ToolWindow = New ToolWindow()
windowBottomRight.Text = "Window Bottom Right"
Me.RadDock1.DockWindow(windowBottomRight, windowBottom, DockPosition.Right)
Dim document1 As DocumentWindow = New DocumentWindow()
document1.Text = "Document 1"
Me.RadDock1.AddDocument(document1)
Dim document2 As DocumentWindow = New DocumentWindow()
document2.Text = "Document 2"
Me.RadDock1.AddDocument(document2)
Dim document3 As DocumentWindow = New DocumentWindow()
document3.Text = "Document 3"
Me.RadDock1.AddDocument(document3)
```
--------------------------------
### Two Axis Offset Example
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/axes/axis-alignment.md
Configures a LineSeries to use two axes with an offset. The horizontal axis starts at the vertical axis's position (0), and the vertical axis starts at the horizontal axis's position (0).
```C#
LineSeries cubicSeries = new LineSeries();
cubicSeries.DataPoints.Add(new CategoricalDataPoint(-27, -3));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(-8, -2));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(-1, -1));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(0, 0));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(1, 1));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(8, 2));
cubicSeries.DataPoints.Add(new CategoricalDataPoint(27, 3));
radChartView1.Series.Add(cubicSeries);
CategoricalAxis cubicHorizontalAxis = cubicSeries.HorizontalAxis as CategoricalAxis;
cubicHorizontalAxis.StartPositionAxis = cubicSeries.VerticalAxis;
cubicHorizontalAxis.StartPositionValue = 0;
LinearAxis cubicVerticalAxis = cubicSeries.VerticalAxis as LinearAxis;
cubicVerticalAxis.StartPositionAxis = cubicSeries.HorizontalAxis;
cubicVerticalAxis.StartPositionValue = 0;
```
```VB.NET
Dim cubicSeries As New LineSeries()
cubicSeries.DataPoints.Add(New CategoricalDataPoint(-27, -3))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(-8, -2))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(-1, -1))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(0, 0))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(1, 1))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(8, 2))
cubicSeries.DataPoints.Add(New CategoricalDataPoint(27, 3))
RadChartView1.Series.Add(cubicSeries)
Dim cubicHorizontalAxis As CategoricalAxis = TryCast(cubicSeries.HorizontalAxis, CategoricalAxis)
cubicHorizontalAxis.StartPositionAxis = cubicSeries.VerticalAxis
cubicHorizontalAxis.StartPositionValue = 0
Dim cubicVerticalAxis As LinearAxis = TryCast(cubicSeries.VerticalAxis, LinearAxis)
cubicVerticalAxis.StartPositionAxis = cubicSeries.HorizontalAxis
cubicVerticalAxis.StartPositionValue = 0;
```
--------------------------------
### Initial Setup of BarSeries
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/series-types/bar.md
Demonstrates how to manually populate two BarSeries with data points. Ensure the ChartView control is initialized before adding series.
```C#
BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
barSeries.Name = "Q1";
barSeries.DataPoints.Add(new CategoricalDataPoint(177, "Harley"));
barSeries.DataPoints.Add(new CategoricalDataPoint(128, "White"));
barSeries.DataPoints.Add(new CategoricalDataPoint(143, "Smith"));
barSeries.DataPoints.Add(new CategoricalDataPoint(111, "Jones"));
barSeries.DataPoints.Add(new CategoricalDataPoint(118, "Marshall"));
this.radChartView1.Series.Add(barSeries);
BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
barSeries2.Name = "Q2";
barSeries2.DataPoints.Add(new CategoricalDataPoint(153, "Harley"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(141, "White"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(130, "Smith"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(88, "Jones"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(109, "Marshall"));
this.radChartView1.Series.Add(barSeries2);
```
```VB.NET
Dim barSeries As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries.Name = "Q1"
barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley"))
barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White"))
barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith"))
barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones"))
barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall"))
Me.RadChartView1.Series.Add(barSeries)
Dim barSeries2 As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries2.Name = "Q2"
barSeries2.DataPoints.Add(New CategoricalDataPoint(153, "Harley"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(141, "White"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(130, "Smith"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(88, "Jones"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(109, "Marshall"))
Me.RadChartView1.Series.Add(barSeries2)
```
--------------------------------
### EnableExactTimeRendering
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/scheduler/properties-methods-events.md
Gets or sets whether appointments are rendered precisely according to their start and end times, or aligned to the scheduler grid lines.
```APIDOC
## Property: EnableExactTimeRendering
### Description
Gets or sets whether appointments are rendered according to their start and end time or are aligned to the scheduler grid lines.
### Type
Boolean
```
--------------------------------
### Using BingRestMapProvider
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/map/providers/bingmaps/bingrestmapprovider.md
This code example demonstrates how to initialize and configure the BingRestMapProvider, including setting the Bing Key, enabling session usage, and configuring local file caching.
```APIDOC
## Using BingRestMapProvider
This section provides code examples for initializing and configuring the `BingRestMapProvider`.
### C# Example
```csharp
string cacheFolder = @"..\..\cache";
BingRestMapProvider bingProvider = new Telerik.WinControls.UI.BingRestMapProvider();
bingProvider.UseSession = true;
bingProvider.BingKey = bingKey; // Replace with your actual Bing Maps Key
LocalFileCacheProvider cache = new LocalFileCacheProvider(cacheFolder);
bingProvider.CacheProvider = cache;
this.radMap1.Providers.Add(bingProvider);
```
### VB.NET Example
```vb.net
Dim cacheFolder As String = "..\..\cache"
Dim bingProvider As BingRestMapProvider = New Telerik.WinControls.UI.BingRestMapProvider()
bingProvider.UseSession = True
bingProvider.BingKey = bingKey ' Replace with your actual Bing Maps Key
Dim cache As New LocalFileCacheProvider(cacheFolder)
bingProvider.CacheProvider = cache
Me.radMap1.Providers.Add(bingProvider)
```
### Properties
- **BingKey** (string): Gets or sets the Bing Maps API key. A valid key is required for the provider to function.
- **UseSession** (bool): Gets or sets a value indicating whether to use a session key for requests.
- **CacheProvider** (IProvider): Gets or sets the provider used for data caching. `LocalFileCacheProvider` can be used to cache tiles locally.
- **ImagerySet** (string): Gets or sets the imagery set to be used. Possible values include *Aerial*, *Road*, *CanvasDark*, etc.
- **MaxZoomLevel** (int): Gets or sets the maximum zoom level supported by the provider.
- **MinZoomLevel** (int): Gets or sets the minimum zoom level supported by the provider.
```
--------------------------------
### Start Video Recording in C#
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/webcam/features/recording-video.md
Set the RecordingFilePath to specify where the video will be saved, then call StartRecording to begin the recording process. Ensure the path is valid before calling the method.
```C#
radWebCam1.RecordingFilePath = path + @"\Video1.mp4";
radWebCam1.StartRecording();
```
--------------------------------
### Setup Gantt View with Custom Data Items and Links (VB.NET)
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/ganttview/custom-items/data-items.md
Initializes the RadGanttView control, sets the timeline range, and populates it with custom data items representing summary tasks, sub-tasks, and their dependencies. This VB.NET example demonstrates the equivalent setup to the C# version.
```VB.NET
Public Sub New()
InitializeComponent()
Me.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = New DateTime(2010, 10, 9)
Me.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = New DateTime(2010, 10, 19)
Dim item1 As MyGanttViewDataItem = New MyGanttViewDataItem()
item1.Start = New DateTime(2010, 10, 10)
item1.[End] = New DateTime(2010, 10, 15)
item1.Progress = 30D
item1.Title = "Summary task.1. title"
Dim subitem11 As MyGanttViewDataItem = New MyGanttViewDataItem()
subitem11.Start = New DateTime(2010, 10, 10)
subitem11.[End] = New DateTime(2010, 10, 12)
subitem11.Progress = 10D
subitem11.Title = "Sub-task.1.1 title"
Dim subitem12 As MyGanttViewDataItem = New MyGanttViewDataItem()
subitem12.Start = New DateTime(2010, 10, 12)
subitem12.[End] = New DateTime(2010, 10, 15)
subitem12.Progress = 20D
subitem12.Title = "Sub-task.1.2 title"
item1.Items.Add(subitem11)
item1.Items.Add(subitem12)
Me.radGanttView1.Items.Add(item1)
Dim item2 As MyGanttViewDataItem = New MyGanttViewDataItem()
```
--------------------------------
### Blazor Component in WinForms
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/host-blazor-in-winforms.md
Example of a Blazor component rendering weather data within a Telerik ListView. Ensure the Telerik.UI.for.Blazor NuGet package is installed.
```razor
@context.TemperatureC C°
@context.Summary
@code{
private WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
}
```
--------------------------------
### Initial ScatterLine Series Setup
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/series-types/scatterline.md
Demonstrates how to create and populate two ScatterLineSeries with data points and configure their appearance. Use this for basic chart setup.
```C#
ScatterLineSeries scatterSeries = new ScatterLineSeries();
scatterSeries.DataPoints.Add(new ScatterDataPoint(15, 19));
scatterSeries.DataPoints.Add(new ScatterDataPoint(18, 10));
scatterSeries.DataPoints.Add(new ScatterDataPoint(13, 15));
scatterSeries.DataPoints.Add(new ScatterDataPoint(10, 8));
scatterSeries.DataPoints.Add(new ScatterDataPoint(5, 2));
scatterSeries.PointSize = new SizeF(8, 8);
this.radChartView1.Series.Add(scatterSeries);
ScatterLineSeries scatterSeries2 = new ScatterLineSeries();
scatterSeries2.DataPoints.Add(new ScatterDataPoint(2, 24));
scatterSeries2.DataPoints.Add(new ScatterDataPoint(7, 12));
scatterSeries2.DataPoints.Add(new ScatterDataPoint(15, 10));
scatterSeries2.DataPoints.Add(new ScatterDataPoint(18, 22));
scatterSeries2.DataPoints.Add(new ScatterDataPoint(20, 20));
scatterSeries2.Shape = new RoundRectShape(1);
scatterSeries2.PointSize = new SizeF(8, 8);
this.radChartView1.Series.Add(scatterSeries2);
```
```VB.NET
Dim scatterSeries As New ScatterLineSeries()
scatterSeries.DataPoints.Add(New ScatterDataPoint(15, 19))
scatterSeries.DataPoints.Add(New ScatterDataPoint(18, 10))
scatterSeries.DataPoints.Add(New ScatterDataPoint(13, 15))
scatterSeries.DataPoints.Add(New ScatterDataPoint(10, 8))
scatterSeries.DataPoints.Add(New ScatterDataPoint(5, 2))
scatterSeries.PointSize = New SizeF(8, 8)
Me.radChartView1.Series.Add(scatterSeries)
Dim scatterSeries2 As New ScatterLineSeries()
scatterSeries2.DataPoints.Add(New ScatterDataPoint(2, 24))
scatterSeries2.DataPoints.Add(New ScatterDataPoint(7, 12))
scatterSeries2.DataPoints.Add(New ScatterDataPoint(15, 10))
scatterSeries2.DataPoints.Add(New ScatterDataPoint(18, 22))
scatterSeries2.DataPoints.Add(New ScatterDataPoint(20, 20))
scatterSeries2.Shape = New RoundRectShape(1)
scatterSeries2.PointSize = New SizeF(8, 8)
Me.radChartView1.Series.Add(scatterSeries2)
```
--------------------------------
### Add Telerik NuGet Feed
Source: https://context7.com/telerik/winforms-docs.git/llms.txt
Adds the Telerik NuGet feed to your project's configuration. This is a one-time setup required for installing Telerik packages.
```powershell
dotnet nuget add source https://nuget.telerik.com/v3/index.json `
--name "telerik.com" `
--username "api-key" `
--password "YOUR_API_KEY"
```
--------------------------------
### Implement Virtual Mode with Mock Data Source
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/gridview/features/virtual-mode.md
This snippet demonstrates the basic setup for virtual mode. It initializes a mock data source, sets up event handlers for cell value retrieval and pushing, and configures the grid's virtual mode properties, including row and column counts. Ensure sorting, filtering, and grouping are disabled for optimal virtual mode performance.
```C#
public VirtualMode1()
{
InitializeComponent();
this.radGridView1.EnableSorting = false;
this.radGridView1.EnableFiltering = false;
this.radGridView1.EnableGrouping = false;
this.Load += new EventHandler(Form1_Load);
}
int COUNT = 100;
MockIntegerDataSource dataSource;
void Form1_Load(object sender, EventArgs e)
{
dataSource = new MockIntegerDataSource(COUNT, COUNT);
this.radGridView1.CellValueNeeded += new GridViewCellValueEventHandler(radGridView1_CellValueNeeded);
this.radGridView1.CellValuePushed += new GridViewCellValueEventHandler(radGridView1_CellValuePushed);
radGridView1.VirtualMode = true;
radGridView1.ColumnCount = dataSource.Columns;
this.radGridView1.RowCount = dataSource.Rows;
}
void radGridView1_CellValuePushed(object sender, GridViewCellValueEventArgs e)
{
}
void radGridView1_CellValueNeeded(object sender, GridViewCellValueEventArgs e)
{
e.Value = this.dataSource.Source[e.RowIndex].Data[e.ColumnIndex];
}
```
```VB.NET
Public Sub New()
InitializeComponent()
Me.RadGridView1.EnableSorting = False
Me.RadGridView1.EnableFiltering = False
Me.RadGridView1.EnableGrouping = False
End Sub
Dim COUNT As Integer = 100
Dim dataSource As MockIntegerDataSource
Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
Me.dataSource = New MockIntegerDataSource(COUNT, COUNT)
AddHandler Me.RadGridView1.CellValueNeeded, AddressOf radGridView1_CellValueNeeded
AddHandler Me.RadGridView1.CellValuePushed, AddressOf radGridView1_CellValuePushed
RadGridView1.VirtualMode = True
RadGridView1.ColumnCount = Me.dataSource.Columns
Me.RadGridView1.RowCount = Me.dataSource.Rows
End Sub
Sub radGridView1_CellValuePushed(ByVal sender As Object, ByVal e As GridViewCellValueEventArgs)
End Sub
Sub radGridView1_CellValueNeeded(ByVal sender As Object, ByVal e As GridViewCellValueEventArgs)
e.Value = Me.dataSource.Source(e.RowIndex).Data(e.ColumnIndex)
End Sub
```
--------------------------------
### Setup LocalMapProvider
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/map/providers/localmapprovider.md
Configure the LocalMapProvider by setting the directory path, file format for tiles, and zoom level range. Then, add the provider to the map control's providers collection.
```C#
string mapFolder = @"..\..\World";
LocalMapProvider provider = new LocalMapProvider();
provider.DirectoryPath = mapFolder;
provider.FileFormat = "os_{0}_{1}_{2}.png";
provider.MinZoomLevel = 1;
provider.MaxZoomLevel = 9;
radMap1.Providers.Add(provider);
```
```VB.NET
Dim mapFolder As String = "..\..\World"
Dim provider As New LocalMapProvider()
provider.DirectoryPath = mapFolder
provider.FileFormat = "os_{0}_{1}_{2}.png"
provider.MinZoomLevel = 1
provider.MaxZoomLevel = 9
radMap1.Providers.Add(provider)
```
--------------------------------
### Filter ListView Items by Value
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/listview/features/filtering.md
Create a FilterDescriptor to filter items based on their 'Value' property. This example filters for items whose values start with 'Local'.
```C#
FilterDescriptor valueFilter = new FilterDescriptor("Value", FilterOperator.StartsWith, "Local");
radListView1.FilterDescriptors.Add(valueFilter);
```
```VB.NET
Dim valueFilter As New FilterDescriptor("Value", FilterOperator.StartsWith, "Local")
RadListView1.FilterDescriptors.Add(valueFilter)
```
--------------------------------
### Usage Example (C#)
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/create-standalone-radexpressioneditor-form.md
Demonstrates how to instantiate the standalone form, show it with an initial value, and retrieve the result. This requires only a few lines of code.
```csharp
StandaloneExpressionEditorForm form = new StandaloneExpressionEditorForm();
if (form.ShowDialog(this.radTextBox1.Text) == System.Windows.Forms.DialogResult.OK)
{
this.radTextBox2.Text = form.ReturnValue;
}
```
--------------------------------
### Select Clicked Word in RadSyntaxEditor (C#)
Source: https://github.com/telerik/winforms-docs.git/blob/master/knowledge-base/select-clicked-word-in-syntax-editor.md
Subscribe to the MouseDown event to get the click position, determine the word's start and end, and then select the word.
```csharp
private void RadSyntaxEditor1_MouseDown(object sender, MouseEventArgs e)
{
System.Drawing.Point position = this.radSyntaxEditor1.SyntaxEditorElement.EditorPresenter.PointFromControl(e.Location);
CaretPosition clickPosition = this.radSyntaxEditor1.SyntaxEditorElement.EditorPresenter.GetPositionFromViewPoint(position);
CaretPosition start = new CaretPosition(clickPosition);
start.MoveToCurrentWordStart();
CaretPosition end = new CaretPosition(clickPosition);
end.MoveToCurrentWordEnd();
this.radSyntaxEditor1.SyntaxEditorElement.Selection.Select(start, end);
}
```
--------------------------------
### Get Timeline Cell Info for Decade Range (VB.NET)
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/ganttview/timeline/custom-timeline.md
Overrides the base method to determine the number of cells and their start index for a given timeline data item within a custom decade range. It calculates the number of years to display based on whether the item is at the start or end of the timeline.
```vbnet
Public Overrides Function GetTimelineCellInfoForItem(item As GanttViewTimelineDataItem, timeRange As TimeRange) As GanttTimelineCellsInfo
If timeRange <> TimeRange.Custom Then
Return MyBase.GetTimelineCellInfoForItem(item, timeRange)
End If
Return Me.GetTimelineCellInfoForDecadeRange(item)
End Function
Public Function GetTimelineCellInfoForDecadeRange(item As GanttViewTimelineDataItem) As GanttTimelineCellsInfo
Dim years As Integer = 10
If item.Start = Me.AdjustedTimelineStart Then
If item.Start.Year Mod 10 > 0 Then
years = 10 - (item.Start.Year Mod 10)
End If
End If
If item.End = Me.AdjustedTimelineEnd Then
If item.End.Year Mod 10 > 0 Then
years = item.End.Year Mod 10
End If
End If
Return New GanttTimelineCellsInfo(years)
End Function
```
--------------------------------
### Setup LocalMapProvider
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/map/providers/localmapprovider.md
This code demonstrates how to set up and configure a LocalMapProvider to load map tiles from a local directory. It specifies the directory path, the naming convention for image files (including zoom and tile coordinates), and the zoom level range.
```APIDOC
## Setup LocalMapProvider
### Description
This code demonstrates how to set up and configure a LocalMapProvider to load map tiles from a local directory. It specifies the directory path, the naming convention for image files (including zoom and tile coordinates), and the zoom level range.
### Method
```csharp
// C# Example
string mapFolder = @"..\..\World";
LocalMapProvider provider = new LocalMapProvider();
provider.DirectoryPath = mapFolder;
provider.FileFormat = "os_{0}_{1}_{2}.png";
provider.MinZoomLevel = 1;
provider.MaxZoomLevel = 9;
radMap1.Providers.Add(provider);
```
### Method
```vb.net
' VB.NET Example
Dim mapFolder As String = "..\..\World"
Dim provider As New LocalMapProvider()
provider.DirectoryPath = mapFolder
provider.FileFormat = "os_{0}_{1}_{2}.png"
provider.MinZoomLevel = 1
provider.MaxZoomLevel = 9
radMap1.Providers.Add(provider)
```
### Notes
The `FileFormat` property specifies the exact format of the image files. The parameters are tile X (*{0}*), Y (*{1}*), and Zoom level (*{2}*). For example, `os_X_Y_Z.png`.
```
--------------------------------
### Initial Setup of Bubble Series
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/chartview/series-types/bubble.md
Demonstrates how to create and populate two BubbleSeries with data points. Use this to visualize data where each point has an X, Y, and size value.
```C#
BubbleSeries bubbleSeries = new BubbleSeries();
bubbleSeries.Name = "Q1";
bubbleSeries.DataPoints.Add(new BubbleDataPoint(15, 19,3));
bubbleSeries.DataPoints.Add(new BubbleDataPoint(18, 10,15));
bubbleSeries.DataPoints.Add(new BubbleDataPoint(13, 15,8));
bubbleSeries.DataPoints.Add(new BubbleDataPoint(10, 8,4));
bubbleSeries.DataPoints.Add(new BubbleDataPoint(5, 12,3));
this.radChartView1.Series.Add(bubbleSeries);
BubbleSeries bubbleSeries2 = new BubbleSeries();
bubbleSeries2.Name = "Q2";
bubbleSeries2.DataPoints.Add(new BubbleDataPoint(20, 20,4));
bubbleSeries2.DataPoints.Add(new BubbleDataPoint(15, 10,3));
bubbleSeries2.DataPoints.Add(new BubbleDataPoint(7, 6,6));
bubbleSeries2.DataPoints.Add(new BubbleDataPoint(18, 22,2));
bubbleSeries2.DataPoints.Add(new BubbleDataPoint(10, 10,4));
this.radChartView1.Series.Add(bubbleSeries2);
```
```VB.NET
Dim bubbleSeries As New BubbleSeries()
bubbleSeries.Name = "Q1"
bubbleSeries.DataPoints.Add(New BubbleDataPoint(15, 19, 3))
bubbleSeries.DataPoints.Add(New BubbleDataPoint(18, 10, 15))
bubbleSeries.DataPoints.Add(New BubbleDataPoint(13, 15, 8))
bubbleSeries.DataPoints.Add(New BubbleDataPoint(10, 8, 4))
bubbleSeries.DataPoints.Add(New BubbleDataPoint(5, 12, 3))
Me.RadChartView1.Series.Add(bubbleSeries)
Dim bubbleSeries2 As New BubbleSeries()
bubbleSeries2.Name = "Q2"
bubbleSeries2.DataPoints.Add(New BubbleDataPoint(20, 20, 4))
bubbleSeries2.DataPoints.Add(New BubbleDataPoint(15, 10, 3))
bubbleSeries2.DataPoints.Add(New BubbleDataPoint(7, 6, 6))
bubbleSeries2.DataPoints.Add(New BubbleDataPoint(18, 22, 2))
bubbleSeries2.DataPoints.Add(New BubbleDataPoint(10, 10, 4))
Me.RadChartView1.Series.Add(bubbleSeries2)
```
--------------------------------
### Get Timeline Cell Info for Decade Range (C#)
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/ganttview/timeline/custom-timeline.md
Overrides the base method to determine the number of cells and their start index for a given timeline data item within a custom decade range. It calculates the number of years to display based on whether the item is at the start or end of the timeline.
```csharp
public override GanttTimelineCellsInfo GetTimelineCellInfoForItem(GanttViewTimelineDataItem item, TimeRange timeRange)
{
if (timeRange != TimeRange.Custom)
{
return base.GetTimelineCellInfoForItem(item, timeRange);
}
return this.GetTimelineCellInfoForDecadeRange(item);
}
public GanttTimelineCellsInfo GetTimelineCellInfoForDecadeRange(GanttViewTimelineDataItem item)
{
int years = 10;
if (item.Start == this.AdjustedTimelineStart)
{
if (item.Start.Year % 10 > 0)
{
years = 10 - (item.Start.Year % 10);
}
}
if (item.End == this.AdjustedTimelineEnd)
{
if (item.End.Year % 10 > 0)
{
years = item.End.Year % 10;
}
}
return new GanttTimelineCellsInfo(years);
}
```
--------------------------------
### Create Custom DockingGuidesTemplate in C#
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/dock/architecture-and-features/dockingguidestemplate.md
This C# code demonstrates how to instantiate a DockingGuidesTemplate, set various image resources for different docking states (normal, hot, background), and define their positions on the center background image. Finally, it assigns the custom template to the RadDock control.
```csharp
DockingGuidesTemplate template;
void Form1_Load(object sender, EventArgs e)
{
template = new DockingGuidesTemplate();
template.DockingHintBackColor = Color.FromArgb(30, Color.Green);
template.DockingHintBorderColor = Color.FromArgb(30, Color.DarkGreen);
template.LeftImage.Image = Properties.Resources.Left;
template.TopImage.Image = Properties.Resources.Top;
template.RightImage.Image = Properties.Resources.Right;
template.BottomImage.Image = Properties.Resources.Bottom;
template.FillImage.Image = Properties.Resources.Fill;
template.LeftImage.HotImage = Properties.Resources.LeftHot;
template.TopImage.HotImage = Properties.Resources.TopHot;
template.RightImage.HotImage = Properties.Resources.RightHot;
template.BottomImage.HotImage = Properties.Resources.BottomHot;
template.FillImage.HotImage = Properties.Resources.FillHot;
template.CenterBackgroundImage.Image = Properties.Resources.Center;
template.LeftImage.LocationOnCenterGuide = new Point(0, 28);
template.TopImage.LocationOnCenterGuide = new Point(28, 0);
template.RightImage.LocationOnCenterGuide = new Point(65, 28);
template.BottomImage.LocationOnCenterGuide = new Point(28, 65);
template.FillImage.LocationOnCenterGuide = new Point(28, 28);
this.radDock1.DockingGuidesTemplate = template;
}
```
--------------------------------
### Custom Rendering Setup for RadRangeSelector
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/rangeselector/properties-and-events.md
Subscribe to the CreateRenderer event on the RangeSelectorViewElement to implement custom chart rendering. This example also sets up a basic LineSeries for the associated chart.
```C#
public RadRangeSelectorCustomRenderer()
{
InitializeComponent();
this.radChartView1.CreateRenderer += OnCreateRenderer;
this.radChartView1.ShowPanZoom = true;
LineSeries series = new LineSeries();
Random rnd = new Random();
for (int i = 0; i < 30; i++)
{
series.DataPoints.Add(new CategoricalDataPoint(rnd.Next(0, 30), DateTime.Now.AddDays(i)));
}
this.radChartView1.Series.Add(series);
series.VerticalAxis.LabelFormat = "{0}°";
series.HorizontalAxis.LabelFormat = "{0:M}";
series.HorizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine;
this.radChartView1.ShowGrid = true;
this.radRangeSelector1.AssociatedControl = this.radChartView1;
RangeSelectorViewElement chartElement = this.radRangeSelector1.RangeSelectorElement.AssociatedElement as RangeSelectorViewElement;
chartElement.CreateRenderer += OnCreateRenderer;
}
private void OnCreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
e.Renderer = new CustomCartesianRenderer((CartesianArea)e.Area);
}
```
```VB.NET
Public Sub New()
InitializeComponent()
AddHandler Me.radChartView1.CreateRenderer, AddressOf OnCreateRenderer
Me.radChartView1.ShowPanZoom = True
Dim series As New LineSeries()
Dim rnd As New Random()
For i As Integer = 0 To 29
series.DataPoints.Add(New CategoricalDataPoint(rnd.[Next](0, 30), DateTime.Now.AddDays(i)))
Next
Me.radChartView1.Series.Add(series)
series.VerticalAxis.LabelFormat = "{0}°"
series.HorizontalAxis.LabelFormat = "{0:M}"
series.HorizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine
Me.radChartView1.ShowGrid = True
Me.radRangeSelector1.AssociatedControl = Me.radChartView1
Dim chartElement As RangeSelectorViewElement = TryCast(Me.radRangeSelector1.RangeSelectorElement.AssociatedElement, RangeSelectorViewElement)
AddHandler chartElement.CreateRenderer, AddressOf OnCreateRenderer
End Sub
Private Sub OnCreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs)
e.Renderer = New CustomCartesianRenderer(DirectCast(e.Area, CartesianArea))
End Sub
```
--------------------------------
### Data Source Initialization (C#)
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/datalayout/change-the-editor-to-a-bound-raddropdownlist.md
Initializes lists of ProductModel and SupplierModel objects, populating them with sample data. This setup is required before binding them to controls.
```C#
List productList;
List suplierList;
BindingSource productsBinding;
public DataLayoutChangeEditor()
{
InitializeComponent();
productList = new List();
suplierList = new List();
productList.Add(new ProductModel(1, "Chai"));
productList.Add(new ProductModel(2, "Chang"));
productList.Add(new ProductModel(3, "Aniseed Syrup"));
productList.Add(new ProductModel(4, "Chef Anton's Gumbo Mix"));
productList.Add(new ProductModel(5, "Tofu"));
productList.Add(new ProductModel(null, "Sir Rodney's Marmalade"));
productList.Add(new ProductModel(6, "Boston Crab Meat"));
productList.Add(new ProductModel(5, "Chartreuse verte"));
productList.Add(new ProductModel(2, "Ravioli Angelo"));
productList.Add(new ProductModel(4, "Perth Pasties"));
suplierList.Add(new SupplierModel(1, "Exotic Liquids"));
suplierList.Add(new SupplierModel(2, "New Orleans Cajun Delights"));
suplierList.Add(new SupplierModel(3, "Tokyo Traders"));
suplierList.Add(new SupplierModel(4, "Norske Meierier"));
suplierList.Add(new SupplierModel(5, "New England Seafood Cannery"));
```
--------------------------------
### Get Result Fragment for Custom Field
Source: https://github.com/telerik/winforms-docs.git/blob/master/controls/richtexteditor/features/fields-and-document-variables/custom-fields.md
Override this method to customize the fragment returned when the ResultFragment is requested. This example creates a fragment from a Span containing a custom property.
```C#
protected override DocumentFragment GetResultFragment()
{
return DocumentFragment.CreateFromInline(new Span(this.MyProperty));
}
```
```VB.NET
Protected Overrides Function GetResultFragment() As DocumentFragment
Return DocumentFragment.CreateFromInline(New Span(Me.MyProperty))
End Function
```