RadVirtualGrid is created to support a million records or more. Still it contains some "heavy" operations like CopySelection/CutSelection/Paste which can take a long time.
I would like to intercept these methods so I can show a "Please wait"-window during the operation. Furthermore I have the need to set a flag to true when such a operation is executing.
We work with a RadGridView with 145000 rows and 4 columns. We use copy-paste to move data around from other apps and the application with build with Telerik.
When we copy a flat file (with tabs delimited fields) and we paste it to the RadGridView, the whole process is painfully slow. The function to retrieve the data from the clipboard takes minutes (maybe hours, I cancelled it). It tracked the cause down to the StringTokenizer class. The tokenizer splits the string up into separate fields. But after extracting a field it creates a new copy of that string (containing about 10MB of data) minus the field. I patched it (with HarmonyX) and now it takes only one second:
static class StringTokenizerPerformancePatch
{
static private readonly InstanceFieldAccessor<StringTokenizer, LinkedList<string>> _tokens = new InstanceFieldAccessor< StringTokenizer, LinkedList<string>>("tokens");
static private readonly InstanceFieldAccessor<StringTokenizer, string> _sourceString = new InstanceFieldAccessor<StringTokenizer, string>("sourceString");
static private readonly InstanceFieldAccessor< StringTokenizer, string> _delimiter = new InstanceFieldAccessor<StringTokenizer, string>("delimiter");
static private readonly InstanceFieldAccessor< StringTokenizer, IEnumerator<string>> _enumerator = new InstanceFieldAccessor<StringTokenizer, IEnumerator<string>>("enumerator");
[HarmonyPatch(typeof(StringTokenizer), "Tokenize")]
staticclassPatch_StringTokenizer_Tokenize
{
static bool Prefix(StringTokenizer __instance)
{
var tokens = _tokens.GetValue(__instance);
var sourceString = _sourceString.GetValue(__instance);
var delimiter = _delimiter.GetValue(__instance);
Tokenize(tokens, sourceString, delimiter);
_enumerator.SetValue(__instance, tokens.GetEnumerator());
returnfalse;
}
static private void Tokenize(LinkedList<string> tokens, string text, string delimiter)
{
tokens.Clear();
if (string.IsNullOrEmpty(text))
return;
int index = 0;
while(true)
{
var index2 = text.IndexOf(delimiter, index, StringComparison.Ordinal);
if (index2 < 0)
{
tokens.AddLast(text.Substring(index));
break;
}
string token = text.Substring(index, index2 - index);
tokens.AddLast(token);
index = index2 + delimiter.Length;
}
}
}
}
Please update your tokanizer to increase performance. While you are at it:Our clients can download different product files from their Telerik account:
https://docs.telerik.com/devtools/winforms/installation-and-upgrades/download-product-files
Currently, when Digitally Signed Assemblies are necessary, they submit support tickets and the support engineers provide the signed assemblies. It would be nice to be directly uploaded to the Telerik account like the rest of the product files.
This is about this method:
public void SetError(GridViewCellCancelEventArgs e, Exception exception)
{
GridViewDataErrorEventArgs args = new GridViewDataErrorEventArgs(exception, 0, 0, GridViewDataErrorContexts.Commit);
if (e != null)
{
args = new GridViewDataErrorEventArgs(exception, e.ColumnIndex, e.RowIndex, GridViewDataErrorContexts.Commit);
}
this.EventDispatcher.RaiseEvent<GridViewDataErrorEventArgs>(EventDispatcher.DataError, this, args);
if (args.ThrowException)
{
throw args.Exception;
}
if (args.Cancel)
{
//TODO: cancel row edit
}
}
The method GridViewTemplate.SetError accepts a parameter of type GridViewCellCancelEventArgs (named e), but uses the information to create a new object of type GridViewDataErrorEventArgs (named args) and uses information from e to fill args.
The method then fires an event with args. Args also has a property Cancel which can be set in the event handlers. But nothing is done with that property.
Parameter e also has a property Cancel which is never be filled. So it could be useful, at the end of SetError, to set e.Cancel with args.Cancel. This way the caller can use the Cancel information from the events.
This request is also related to my next request.
PS: Why is GridViewCellCancelEventArgs called this way? It implies it has arguments for an event, but it is not used for an event, am I right?
The assembly is required for our RadMarkupEditor using the IE rendering engine. It allows you to specify HTML-like text formatting at design time in the Properties window of Visual studio:
The ChartLegendElement displays the legend items in a StackLayoutElement which can be either vertical or horizontal.
public RadForm1()
{
InitializeComponent();
Random rand = new Random();
List<LineSeries> list = new List<LineSeries>();
for (var index = 1; index <= 15; index++)
{
LineSeries ls = new LineSeries();
ls.LegendTitle = "Series " + index;
list.Add(ls);
}
for (int index = 1; index <= 100; index++)
{
foreach (LineSeries s in list)
s.DataPoints.Add(new CategoricalDataPoint(index, rand.Next(0, rand.Next(5, 20))));
}
this.radChartView1.Series.AddRange(list.ToArray());
this.radChartView1.ShowLegend = true;
this.radChartView1.ChartElement.LegendPosition = LegendPosition.Bottom;
this.radChartView1.ChartElement.LegendElement.StackElement.Orientation = Orientation.Vertical;
}
Horizontal:
Vertical:
It would be good to provide an option for wrapping the legend items:
Workaround: use an appropriate container for the legend items to wrap the legend item and use the space more efficiently
https://docs.telerik.com/devtools/winforms/knowledge-base/chartview-wrap-legend-items
This is about the following method:
public void SetError(GridViewCellCancelEventArgs e, Exception exception)
{
GridViewDataErrorEventArgs args = new GridViewDataErrorEventArgs(exception, 0, 0, GridViewDataErrorContexts.Commit);
if (e != null)
{
args = new GridViewDataErrorEventArgs(exception, e.ColumnIndex, e.RowIndex, GridViewDataErrorContexts.Commit);
}
this.EventDispatcher.RaiseEvent<GridViewDataErrorEventArgs>(EventDispatcher.DataError, this, args);
if (args.ThrowException)
{
throw args.Exception;
}
if (args.Cancel)
{
//TODO: cancel row edit
}
}
Right now, the method GridViewTemplate.SetError accepts a parameter of type GridViewCellCancelEventArgs, which in itself is weird, because event args should only be used inside events and OnXXX-methods. But since SetError fires an event, one could argue that this method is like a OnXXX-method.
But inside it becomes more weird, it translates GridViewCellCancelEventArgs into GridViewDataErrorEventArgs. And I must admit, the last DataError-args feel a lot more logical that CellCancel-args when firing setting an error. Furthermore, if I create an override of class GridViewCellCancelEventArgs to contain more data about an error, this information never reaches the event handlers.
So why this translation? Or better: Why this parameter?
My suggestion would be to make a new overload:
public void SetError(GridViewDataErrorEventArgs e)
{
if (e == null)
throw new ArgumentNullException(nameof(e));
this.EventDispatcher.RaiseEvent<GridViewDataErrorEventArgs>(EventDispatcher.DataError, this, args);
if (args.ThrowException)
throw args.Exception;
if (args.Cancel)
{
// TODO: I really do not know what telerik wanted to do here, so I live this up to Telerik.
}
}
I am rewriting the RadGridViewPaste-mechanism. Therefor I want to call PastingCellClipboardContent-event using the EventDispatcher.CellClipboardPaste. therefor I need the class GridViewCellValueEventArgs. It has two constructors:
The second constructor is marked as Internal, not Public.
Request: Can this constructor be made Public?
The snap layouts window can be opened by using the Win+Z keyboard combination, but when the mouse is over the Maximize button of RadForm, the window is not shown.
MSDN information is available here: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/apply-snap-layout-menu
Following the guides from MSDN, we need to override the WndProc method of the form, listen to the WM_NCHITTEST message, and return HTMAXBUTTON result when the mouse is over the maximize button.
private const int HTMAXBUTTON = 9;
protected override void WndProc(ref Message m)
{
if (m.Msg == NativeMethods.WM_NCHITTEST)
{
// Get the hit test location from message parameters
Point location = this.ParseIntPtr(m.LParam);
location = this.GetMappedWindowPoint(location);
// Get the hit tested element and check if it is the Maximize button
RadElement element = this.ElementTree.GetElementAtPoint(location);
if (element == this.FormElement.TitleBar.MaximizeButton)
{
m.Result = new IntPtr(HTMAXBUTTON);
return;
}
}
base.WndProc(ref m);
}
private Point ParseIntPtr(IntPtr param)
{
if (IntPtr.Size == 4) //x86
{
return new Point(param.ToInt32());
}
else //x64
{
long intParam = param.ToInt64();
short x = (short)intParam;
short y = (short)(intParam >> 16);
return new Point(x, y);
}
}
protected virtual Point GetMappedWindowPoint(Point screenPoint)
{
NativeMethods.POINT inputPoint = new NativeMethods.POINT();
inputPoint.x = screenPoint.X;
inputPoint.y = screenPoint.Y;
if (this.IsHandleCreated)
{
NativeMethods.MapWindowPoints(new HandleRef(this, IntPtr.Zero), new HandleRef(this, this.Handle), inputPoint, 1);
}
return new Point(
inputPoint.x + this.FormBehavior.ClientMargin.Left,
inputPoint.y + this.FormBehavior.ClientMargin.Top);
}
hi...
A Callout Control is in your roadmap for winforms please ?
thx in advance...
regards,
When importing a document containing Outlines (Bookmarks) containing Actions with an empty dictionary:
<</Title(Bookmarks)/Parent .../First .../Last .../Prev .../A<<>>/Count ...>
leads to an exception thrown: System.MissingMethodException: 'Cannot create an abstract class.'