Hello Telerik,
How could I play with margin and padding to add some spacing between image, texte and certainly my checkboxe ?
Thank you in advance for your support !
I want to execute some code when a user types and then uses the Mouse to click on an item in the list.
I will need to access the item selected.
I am having a hard time to find the correct event to capture this.
Thanks.

Hi.
As is known, Ctrl + A selects all cells in the spreadsheet. Can we change this to only select cells that are full?
Hi,
I don't know if this is the correct forum for this question but I couldn't find an Excel export/import forum which might be more suitable.
I'm using GridViewSpreadStreamExport to export RadGridViews to Excel which works fine and I can open the generated spreadsheet in Excel without any issues.
The issue comes when I try to open/read the generated spreadsheet in code using OleDbCommand with the following connection string:
@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + path + "; Extended Properties = " + @"""Excel 12.0 Xml;HDR=YES;IMEX=1"";";
I get an "External table is not in the expected format" error message on opening the connection.
If I first open the generated spreadsheet in Excel and just save it, without making any changes to it,the issue does not occur and I can open the spreadsheet in code without any issues.
The spreadsheet does have multiple worksheets, each one from a new instance of a RadGridView, but I don't think that is the issue because generating a spreadsheet with a single worksheet has the same issue.
The RadGridView is in memory, not on the UI, and I just set some of the column headers, width and text alignments.
Export format is SpreadStreamExportFormat.Xlsx and the export of individual RadGridViews are done via:
spreadStreamExport.RunExport(path, new SpreadStreamExportRenderer());
Although I have tried not creating a new instance of SpreadStreamExportRenderer as well.
I've reduced the export to its bare minimum (removed column header and text alignment settings) but nothing has helped.
Any ideas what the issue could be?
Thanks,
Arash

Good day,
I have a radpivotgridview with a custom calculated field, 2 questions:
First one I see in https://docs.telerik.com/devtools/winforms/controls/pivotgrid/calculated-fields to make the custom calculated field from just a value column named ExtendedPrice if I want column a from database div column b from database how could I implement that.
Second I have a calculated field like this:
Public Class TelerikPivotCalculatedFieldDirua
Inherits CalculatedField
Private denboraEuroakField As RequiredField
Public Sub New()
Me.Name = "TotalEuro"
Me.denboraEuroakField = RequiredField.ForProperty("zenbatSeg")
End Sub
Protected Overrides Function RequiredFields() As IEnumerable(Of RequiredField)
Return New List(Of RequiredField) From {denboraEuroakField}
End Function
Protected Overrides Function CalculateValue(aggregateValues As IAggregateValues) As AggregateValue
Dim aggregateValue = aggregateValues.GetAggregateValue(Me.denboraEuroakField)
If aggregateValue.IsError() Then
Return aggregateValue
End If
Dim denboraEuroak As Integer = 0 '= aggregateValue.ConvertOrDefault(Of Integer)()
denboraEuroak = CInt(aggregateValue.GetValue)
If denboraEuroak >= 0 Then
Dim gEurosSeg As Decimal = 0
gEurosSeg = CDec(gEurosHora) / CDec(3600)
Dim gGuztira As Decimal = 0
gGuztira = CDec(denboraEuroak) * CDec(gEurosSeg)
gGuztira = Math.Round(gGuztira, 2, MidpointRounding.AwayFromZero)
Return New DoubleAggregateValue(gGuztira)
End If
Return Nothing
End Function
End Class
In the vb file:
Me.provider = New LocalDataSourceProvider()
'Using rpgestadistica.PivotGridElement.DeferRefresh()
Using provider.DeferRefresh()
Dim calculatedField As New TelerikPivotCalculatedFieldDirua()
calculatedField.Name = "TotalEuro"
calculatedField.DisplayName = Func_nombre(3372)
provider.CalculatedFields.Add(calculatedField)
End Using
'DirectCast(Me.rpgestadistica.DataProvider, LocalDataSourceProvider).CalculatedFields.Add(calculatedField)
'rpgestadistica.DataProvider = provider
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "globalNombre", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(3370)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "tipogasin", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(160)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "suscripcion", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(250)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "razon", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(174)})
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "total", _
.AggregateFunction = AggregateFunctions.Sum})
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "denbora", _
.AggregateFunction = New TelerikPivotAggregateFunctionEstTiempo()})
'Me.provider.AggregateDescriptions.Add(provider.CalculatedFields.Item(11))
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "TotalEuro", _
.AggregateFunction = AggregateFunctions.Sum})
'This last line appears like "error".
Me.cargaridiomarpg()
provider.AggregatesPosition = PivotAxis.Columns
provider.AggregatesLevel = 2
Me.provider.ItemsSource = ldt
rpgestadistica.DataProvider = provider
cargaridiomarpg()
For Each rd As RadElement In Me.rpgestadistica.PivotGridElement.ColumnDescriptorsArea.Children
Dim pgde As PivotGroupDescriptorElement = TryCast(rd, PivotGroupDescriptorElement)
If Not IsNothing(pgde) Then
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitRowHeaders(pgde.Level)
End If
Next
For Each element As RadElement In Me.rpgestadistica.PivotGridElement.RowDescriptorsArea.Children
Dim pgde As PivotGroupDescriptorElement = TryCast(element, PivotGroupDescriptorElement)
If Not IsNothing(pgde) Then
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitRowHeaders(pgde.Level)
End If
Next
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitColumns()
See Attach file 1, CustomAggregatev1:
If I rightClick and deattach TiempoEuro column and reattach it. I see it ok:
See Attach file 2 and Attach file 3.
How can I achive it like in attach file 3 from the beginning instead of having errors.
Thanks in advance,
Xabi
I want to temporarily disable the arrow keys in the grid. When a row is selected, I do some image processing for that row, which typically takes .25 to 2 seconds. During that processing time, I want to disable the arrow keys during processing and then enable them when done. I created a bool isBusy Flag for the processing, but I cannot add that to the below custom behavior. Any suggestions? Is there a way to toggle the Custom behavior?
public class CustomGridBehavior : BaseGridBehavior
{
public override bool ProcessKey(KeyEventArgs keys__1)
{
switch (keys__1.KeyCode)
{
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
{
return false;
}
default:
{
return base.ProcessKey(keys__1);
}
}
}
}

I have a win form on which I have a radribbon component which was working fine.
After I processed an update to Telerik UI components, the form could no longer open in design mode and attached are the error messages.
It looks like a bug, maybe not.
Could anyone assist?
Ekoue

001.internal class NotificationA : INotification {002. public string Name { get; set; }003. public string Type => nameof(NotificationA);004.}005. 006.internal class NotificationB : INotification {007. public int Degree { get; set; }008. public string Type => nameof(NotificationB);009.}010. 011.internal class NotificationAListItem : RadListVisualItem {012. private LightVisualElement notificationTitleElement;013. private StackLayoutPanel stackLayout;014. 015. protected override void CreateChildElements()016. {017. base.CreateChildElements();018. 019. stackLayout = new StackLayoutPanel();020. stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical;021. 022. notificationTitleElement = new LightVisualElement();023. notificationTitleElement.TextAlignment = ContentAlignment.MiddleLeft;024. notificationTitleElement.Margin = new Padding(10);025. notificationTitleElement.ForeColor = Color.Black;026. stackLayout.Children.Add(notificationTitleElement);027. 028. this.Children.Add(stackLayout);029. }030. 031. public override void Synchronize()032. {033. base.Synchronize();034. Text = string.Empty;035. if (Data.DataBoundItem is not NotificationA n) return;036. notificationTitleElement.Text = Convert.ToString(n.Name);037. }038. }039. 040.internal class NotificationBListItem : RadListVisualItem041. {042. private LightVisualElement notificationTitleElement;043. private StackLayoutPanel stackLayout;044. 045. protected override void CreateChildElements()046. {047. base.CreateChildElements();048. 049. stackLayout = new StackLayoutPanel();050. stackLayout.Orientation = Orientation.Vertical;051. 052. 053. notificationTitleElement = new LightVisualElement();054. notificationTitleElement.TextAlignment = ContentAlignment.MiddleLeft;055. notificationTitleElement.Margin = new Padding(10);056. notificationTitleElement.ForeColor = Color.Black;057. stackLayout.Children.Add(notificationTitleElement);058. 059. Children.Add(stackLayout);060. 061. Padding = new Padding(5);062. Shape = new RoundRectShape(3);063. BorderColor = Color.FromArgb(255, 110, 153, 210);064. BorderGradientStyle = GradientStyles.Solid;065. DrawBorder = true;066. DrawFill = true;067. BackColor = Color.FromArgb(255, 230, 238, 254);068. GradientStyle = GradientStyles.Solid;069. }070. 071. public override void Synchronize()072. {073. base.Synchronize();074. Text = string.Empty;075. if (Data.DataBoundItem is not NotificationB n) return;076. notificationTitleElement.Text = Convert.ToString(n.Degree);077. }078.}079. 080.public partial class TestForm : RadForm {081. public TestForm() {082. InitializeComponent();083. InitializeViewAppearance();084. }085. 086. private void InitializeViewAppearance() {087. var notifications = new List<INotification> {088. new NotificationA {Name = "Foo"},089. new NotificationA {Name = "Bar"},090. new NotificationB { Degree = 180 }091. };092. for (var i = 0; i < 100000; i++) {093. notifications.Add(new NotificationA { Name = $"test item {i}" });094. }095. lcNotifications.CreatingVisualListItem += OnNotificationItemCreating;096. lcNotifications.DataSource = notifications;097. }098. 099. private void OnNotificationItemCreating(object sender, CreatingVisualListItemEventArgs args)100. {101. args.VisualItem = args.DataItem.DataBoundItem switch {102. NotificationA _ => new NotificationAListItem(),103. NotificationB _ => new NotificationBListItem(),104. _ => args.VisualItem105. };106. }107. }
I've created a custom cell in a GridView with two labels. It works so long as the grid isn't resized or the number of rows do not exceed the length of the grid. When either of the two occur the custom cells can loose their formatting and cells without formatting adopt traits from the custom formatting.
This snippet demonstrates the issue.
A bump in the right direction would be appreciated.
using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using Telerik.WinControls.Layouts;using Telerik.WinControls.UI;namespace TR_Test{ public partial class GridTest : Telerik.WinControls.UI.RadForm { public GridTest() { InitializeComponent(); //simple grid this.radGridView1.CreateCell += new Telerik.WinControls.UI.GridViewCreateCellEventHandler(this.radGridView1_CreateCell); this.radGridView1.AllowAddNewRow = false; this.radGridView1.AllowSearchRow = false; this.radGridView1.ShowGroupPanel = false; this.radGridView1.ShowRowHeaderColumn = false; this.radGridView1.TableElement.RowHeight = 60; // Populate the grid with data PopulateGrid(); radGridView1.Columns["Info"].Width = 150; } private void PopulateGrid() { List<Sales> myList = new List<Sales>(); myList.Add(new Sales(1, "Outdoor,1111", "asdf", "asdf")); myList.Add(new Sales(2, "Hardware,2222", "asdf", "asdf")); myList.Add(new Sales(3, "Tools,3333", "asdf", "asdf")); myList.Add(new Sales(4, "Books,4444", "asdf", "asdf")); myList.Add(new Sales(5, "Shows,5555", "asdf", "asdf")); myList.Add(new Sales(6, "Mugs,6666", "asdf", "asdf")); myList.Add(new Sales(7, "Phones,7777", "asdf", "asdf")); myList.Add(new Sales(8, "Indore,8888", "asdf", "asdf")); myList.Add(new Sales(9, "Cats,9999", "asdf", "asdf")); myList.Add(new Sales(10, "Dogs,0000", "asdf", "asdf")); myList.Add(new Sales(11, "Outdoor,1111", "asdf", "asdf")); myList.Add(new Sales(12, "Hardware,2222", "asdf", "asdf")); myList.Add(new Sales(13, "Tools,3333", "asdf", "asdf")); myList.Add(new Sales(14, "Books,4444", "asdf", "asdf")); myList.Add(new Sales(15, "Shows,5555", "asdf", "asdf")); myList.Add(new Sales(16, "Mugs,6666", "asdf", "asdf")); myList.Add(new Sales(17, "Phones,7777", "asdf", "asdf")); myList.Add(new Sales(18, "Indore,8888", "asdf", "asdf")); myList.Add(new Sales(19, "Cats,9999", "asdf", "asdf")); myList.Add(new Sales(20, "Dogs,0000", "asdf", "asdf")); radGridView1.BindingContext = new BindingContext(); radGridView1.DataSource = myList; } private void radGridView1_CreateCell(object sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridDataCellElement)) { GridViewDataColumn dataColumn = e.Column as GridViewDataColumn; switch (dataColumn.Name) { case "Info": e.CellType = typeof(SplitCell); break; } } } } public class SplitCell : GridDataCellElement { private StackLayoutPanel panel; private RadLabelElement label1; private RadLabelElement label2; public SplitCell(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override void CreateChildElements() { base.CreateChildElements(); this.panel = new StackLayoutPanel { Margin = new System.Windows.Forms.Padding(5), Orientation = System.Windows.Forms.Orientation.Vertical }; this.label1 = new RadLabelElement { Font = new Font("Segoe UI", 16.0f) }; this.panel.Children.Add(this.label1); this.label2 = new RadLabelElement { Font = new Font("Segoe UI", 9.0f) }; this.panel.Children.Add(this.label2); this.Children.Add(this.panel); } protected override void SetContentCore(object value) { object cellValue = value; this.label1.Text = ""; this.label2.Text = ""; if (cellValue is DBNull || cellValue == null) cellValue = ","; string[] s = cellValue.ToString().Split(','); if (s.Length >= 1) this.label1.Text = s[0]; if (s.Length >= 2) this.label2.Text = s[1]; } } public class Sales { public Sales(int id, string info, string PO, string Paid) { this.ID = id; this.Info = info; this.PO = PO; this.Paid = Paid; } public int ID { get; set; } public string Info { get; set; } public string PO { get; set; } public string Paid { get; set; } }}