Telerik Forums
UI for WinForms Forum
1 answer
315 views
Hi

( First of all I need to clarify that I could manage both C# or VB solution to solve this issue )

I have a RadListControl where I would like to use it to list the runing processes in the system (with a condition that no more than 1 process with the same name),
that thing is done and I'm trying to update the list each 2 seconds (firstly determining If exists changes to update the current list),
I'm saving the SelectedItems property of the control to restore the selected items in the RadListControl after updating the list and here is the problem, after clearing the items of the control using the Items.Clear method the Scrollbar moves up to the top of the control and I need to scrolldown to the desired position again and again.

I would like to keep the current position after updating the items in the control, just like Windows TaskManager does for example.

I also tried to set a collection of RadDataItem as the control DataSource, but then the Image property for each item is empty (I don't know why).

I attached a gif in this post that demonstrates the problem,
As you can see in the Gif, when I run a new process (the window which is at the left border of the gif) the process list is moved to top, and the same thing happens when I close that process.

I don't know what more to try, here is the relevant part of the code:

Private Sub Timer_RefreshProcessList_Tick(ByVal sender As Object, ByVal e As EventArgs) _
Handles Timer_RefreshProcessList.Tick
 
    ' Processes that shouldn't be listed.
    Dim BlackListedProcesses As String() =
        {
            My.Application.Info.AssemblyName,
            "Idle",
            "System",
            "audiodg"
        }
 
    ' Get the runing processes.
    Dim Processes As Process() = Process.GetProcesses
 
    ' Filter the processes by its name
    ' then set the RadListDataItem items containing the names and the process icons.
    Dim ProcessItems As IEnumerable(Of RadListDataItem) =
        (From proc As Process In Processes
        Where Not BlackListedProcesses.Contains(proc.ProcessName)
        Order By proc.ProcessName Ascending).
        GroupBy(Function(proc As Process) proc.ProcessName).
        Select(Function(procs As IGrouping(Of String, Process))
 
                   If Not procs.First.HasExited Then
                       Try
                           Return New RadListDataItem With
                                  {
                                    .Active = False,
                                    .Text = String.Format("{0}.exe", procs.First.ProcessName),
                                    .Image = ResizeImage(Icon.ExtractAssociatedIcon(procs.First.MainModule.FileName).ToBitmap,
                                                         Width:=16, Height:=16)
                                  }
 
                       Catch ex As Exception
                           Return Nothing
                       End Try
 
                   Else
                       Return Nothing
                   End If
 
               End Function)
 
    ' If the RadListControl does not contain any item then...
    If Me.RadListControl_ProcessList.Items.Count = 0 Then
 
        With Me.RadListControl_ProcessList
            .BeginUpdate()
            .Items.AddRange(ProcessItems) ' Add the RadListDataItems for first time.
            .EndUpdate()
        End With
 
        Exit Sub
 
    End If
 
    ' If RadListDataItems count is not equal than the runing process list count then...
    If Me.RadListControl_ProcessList.Items.Count <> ProcessItems.Count Then
 
        ' Save the current selected items.
        Dim SelectedItems As IEnumerable(Of String) =
            From Item As RadListDataItem
            In Me.RadListControl_ProcessList.SelectedItems
            Select Item.Text
 
        ' For Each ctrl As RadListDataItem In ProcessItems
        '     ctrl.Dispose()
        ' Next
 
        With Me.RadListControl_ProcessList
 
            ' .AutoScroll = False
            ' .SuspendSelectionEvents = True
            ' .SuspendItemsChangeEvents = True
            ' .SuspendLayout()
            ' .BeginUpdate()
            .Items.Clear() ' Clear the current RadListDataItems
            .Items.AddRange(ProcessItems) ' Add the new RadListDataItems.
            ' .EndUpdate()
            ' .ResumeLayout()
 
        End With
 
        ' Restore the selected item(s).
        For Each Item As RadListDataItem In Me.RadListControl_ProcessList.Items
 
            If SelectedItems.Contains(Item.Text) Then
 
                Item.Selected = True
                Item.Active = True
 
                With Me.RadListControl_ProcessList
                    ' .ScrollToItem(Item)
                    ' .ListElement.ScrollToItem(Item)
                    ' .ListElement.ScrollToActiveItem()
                End With
 
            End If
 
        Next Item
 
        With Me.RadListControl_ProcessList
            ' .AutoScroll = True
            ' .SuspendSelectionEvents = False
            ' .SuspendItemsChangeEvents = False
        End With
 
    End If
 
End Sub

Thanks in advance.

PS:

What I did time ago to solve this issue with a normal ListBox control is this (I can't reproduce it in a RadListControl):

' [ListBox] Select item without jump
'
' Original author of code is "King King"
' Url: stackoverflow.com/questions/19479774/how-to-prevent-listbox-jumps-to-item
'
' Examples :
'
' Select_Item_Without_Jump(ListBox1, 50, ListBoxItemSelected.Select)
'
' For x As Integer = 0 To ListBox1.Items.Count - 1
'    Select_Item_Without_Jump(ListBox1, x, ListBoxItemSelected.Select)
' Next
 
''' <summary>
''' Indicates whether the ListBox Item should be Selected or Unselected.
''' </summary>
Private Enum ListBoxItemSelected
 
    ''' <summary>
    ''' Indicate that ListBox Item should be Selected.
    ''' </summary>
    [Select] = 1
 
    ''' <summary>
    ''' Indicate that ListBox Item should be Unselected.
    ''' </summary>
    [Unselect] = 0
 
End Enum
 
''' <summary>
''' Selects or unselects a ListBox Item without jumping to the Item location on the layout.
''' </summary>
Public Shared Sub Select_Item_Without_Jump(lb As ListBox, index As Integer, selected As ListBoxItemSelected)
    Dim i As Integer = lb.TopIndex ' Store the selected item index
    lb.BeginUpdate() ' Disable drawing on control
    lb.SetSelected(index, selected) ' Select the item
    lb.TopIndex = i ' Jump to the previous selected item
    lb.EndUpdate() ' Eenable drawing
End Sub
Dimitar
Telerik team
 answered on 01 Oct 2014
4 answers
210 views
I have Winforms application with ChartView that received real time data and i have label the show the data value. After each point received inside my Timer tick all the points remove in order to show my label only once:private AreaSeries series;

private void timerStatistics_Tick(object sender, EventArgs e)
{
       try
     {
        chartPoints.Add(AdapterStatistics.BitsPerSecond * 0.000001);
        series.DataPoints.Add(new Telerik.Charting.CategoricalDataPoint(AdapterStatistics.BitsPerSecond * 0.000001));

       RemoveLabels();
       series.DataPoints[series.DataPoints.Count - 1].Label = AdapterStatistics.TrafficStatistics;
     }
       catch (Exception)
       { }
}

private void RemoveLabels()
{
     for (int i = 0; i < series.DataPoints.Count - 1; i++)
     series.DataPoints[i].Label = "";
}

my problem is that me label i in the right side of the lase point so almost all the label is hide (see attach file)
Any idea if it possible to remove the label to the left of the last point inside my chart ?






Dimitar
Telerik team
 answered on 01 Oct 2014
13 answers
362 views
For data binding in winform scheduler, i want to update database when the appointment is added, updated rather than when some update button is clicked.

Currently, the documentations provided is perfectly describing how it work with button, and i love it. Nonetheless, i want to find better, and easy way to update appointment, so we can get rid of using update button.

Is there any event property for radscheduelr that i can use in this condition? or Any other way to do this?

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 01 Oct 2014
1 answer
295 views
I am able to add a custom function no problem, however; doing so seems to remove all the default functions (see screenshot). Any ideas on how to add a custom function and leave the default functions as well?

Telerik.Data.Expressions.ExpressionContext.Context = new MyExpressionContext();
Telerik.WinControls.UI.RadExpressionEditorForm.ExpressionItemsList.Add(
    new Telerik.Data.Expressions.ExpressionItem
{
    Name = "MarketDate (Endur)",
    Value = "MarketDate()",
    Syntax = "MarketDate()",
    Type = Telerik.Data.Expressions.ExpressionItemType.OtherFunc,
    Description = "Returns the market date as it appears in the market manager."
});

Using the LoadFromXml function as described in the help has the same results.
Dimitar
Telerik team
 answered on 30 Sep 2014
1 answer
194 views
Hello,

Is it possible to change all the child nodes position, to align with the root node. So all the nodes (root and child) will be aligned at the left. 
And one more question. Is it possible to change the color inside the checkbox or the radio button, and the text in black (in a treeview with checkboxes and radio buttons). 

Thank you in advance

Eduard
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 30 Sep 2014
1 answer
487 views
I am currently converting a VB.net project over to Teleriks components.  On one of my forms i have multiple panels.  When one of the panels get clicked the borderstyle changes to fixed3D and the rest change to FixedSingle.  But, with telerik borderstyle is not a member.  Is there a work away around this?  Do i need to change it from a panel to a label for this feature?  Below is my code.

Thank You

#Region "PRIORITY PANEL SELECT"
    Private Sub Panel2_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel2.Click
        Try
            If Panel2. = BorderStyle.FixedSingle Then
                Panel2.BorderStyle = BorderStyle.Fixed3D
                Panel3.BorderStyle = BorderStyle.FixedSingle
                Panel4.BorderStyle = BorderStyle.FixedSingle
                Panel5.BorderStyle = BorderStyle.FixedSingle
                Panel6.BorderStyle = BorderStyle.FixedSingle
            Else
                Panel2.BorderStyle = BorderStyle.FixedSingle
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Panel3_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel3.Click
        Try
            If Panel3.BorderStyle = BorderStyle.FixedSingle Then
                Panel3.BorderStyle = BorderStyle.Fixed3D
                Panel2.BorderStyle = BorderStyle.FixedSingle
                Panel4.BorderStyle = BorderStyle.FixedSingle
                Panel5.BorderStyle = BorderStyle.FixedSingle
                Panel6.BorderStyle = BorderStyle.FixedSingle
            Else
                Panel3.BorderStyle = BorderStyle.FixedSingle
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Panel4_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel4.Click
        Try
            If Panel4.BorderStyle = BorderStyle.FixedSingle Then
                Panel4.BorderStyle = BorderStyle.Fixed3D
                Panel3.BorderStyle = BorderStyle.FixedSingle
                Panel2.BorderStyle = BorderStyle.FixedSingle
                Panel5.BorderStyle = BorderStyle.FixedSingle
                Panel6.BorderStyle = BorderStyle.FixedSingle
            Else
                Panel4.BorderStyle = BorderStyle.FixedSingle
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Panel5_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel5.Click
        Try
            If Panel5.BorderStyle = BorderStyle.FixedSingle Then
                Panel5.BorderStyle = BorderStyle.Fixed3D
                Panel3.BorderStyle = BorderStyle.FixedSingle
                Panel4.BorderStyle = BorderStyle.FixedSingle
                Panel2.BorderStyle = BorderStyle.FixedSingle
                Panel6.BorderStyle = BorderStyle.FixedSingle
            Else
                Panel5.BorderStyle = BorderStyle.FixedSingle
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Panel6_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel6.Click
        Try
            If Panel6.BorderStyle = BorderStyle.FixedSingle Then
                Panel6.BorderStyle = BorderStyle.Fixed3D
                Panel3.BorderStyle = BorderStyle.FixedSingle
                Panel4.BorderStyle = BorderStyle.FixedSingle
                Panel5.BorderStyle = BorderStyle.FixedSingle
                Panel2.BorderStyle = BorderStyle.FixedSingle
            Else
                Panel6.BorderStyle = BorderStyle.FixedSingle
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
#End Region





George
Telerik team
 answered on 30 Sep 2014
6 answers
208 views

Since upgrading from Q2 2010 (Currently on v.2011.2.11.831), I have found an issue with the checkboxes not drawing properly when you click on the parent check box  which recursively checks all children nodes (see Main 2 –Subs in jpg).  If you expand the node first or after the first time the checkboxes draw properly.  Is there a something I can do to force the redraw so the checkboxes paint correctly?

Below is a sample program and the code I use to recursively check the child nodes. If you click on the checkbox of one of the Mains it will check all children and expand it.

 

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
  
namespace TreeViewTest
{
    public partial class Form1 : Form
    {
        private System.ComponentModel.IContainer components;
  
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        private Telerik.WinControls.UI.RadTreeView radTreeView1;
        private void InitializeComponent()
        {
            this.radTreeView1 = new Telerik.WinControls.UI.RadTreeView();
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).BeginInit();
            this.SuspendLayout();
            // 
            // radTreeView1
            // 
            this.radTreeView1.Location = new System.Drawing.Point(1, 13);
            this.radTreeView1.Name = "radTreeView1";
            this.radTreeView1.Size = new System.Drawing.Size(496, 347);
            this.radTreeView1.SpacingBetweenNodes = -1;
            this.radTreeView1.TabIndex = 0;
            this.radTreeView1.Text = "radTreeView1";
            this.radTreeView1.NodeCheckedChanged += new Telerik.WinControls.UI.RadTreeView.TreeViewEventHandler(this.radTreeView1_NodeCheckedChanged);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(497, 372);
            this.Controls.Add(this.radTreeView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.radTreeView1)).EndInit();
            this.ResumeLayout(false);
  
        }
  
        public Form1()
        {
            InitializeComponent();
        }
  
        private void radTreeView1_NodeCheckedChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
        {
            this.radTreeView1.NodeCheckedChanged -= radTreeView1_NodeCheckedChanged;
            if (e.Node.Nodes.Count > 0)
            {
                this.CheckAllChildNodes(e.Node, e.Node.Checked);
            }
            e.Node.Expanded = true;
            RadTreeNode topNode = GetTopNode(e.Node);
            CheckAllChildNodesForChecked(topNode);
            this.radTreeView1.NodeCheckedChanged += new RadTreeView.TreeViewEventHandler(radTreeView1_NodeCheckedChanged);
  
        }
        private void CheckAllChildNodes(RadTreeNode treeNode, bool nodeChecked)
        {
            foreach (RadTreeNode node in treeNode.Nodes)
            {
                node.Checked = nodeChecked;
                if (node.Nodes.Count > 0)
                {
                    this.CheckAllChildNodes(node, nodeChecked);
                }
            }
        }
        private bool CheckAllChildNodesForChecked(RadTreeNode treeNode)
        {
            bool childChecked = false;
            foreach (RadTreeNode node in treeNode.Nodes)
            {
                if (node.Nodes.Count > 0)
                {
                    if (this.CheckAllChildNodesForChecked(node))
                    {
                        childChecked = true;
                    }
                }
                else
                {
                    if (!childChecked)
                    {
                        childChecked = node.Checked;
                    }
                }
            }
            if (childChecked)
            {
                treeNode.Checked = true;
            }
            else
            {
                treeNode.Checked = false;
            }
  
            return childChecked;
        }
        private RadTreeNode GetTopNode(RadTreeNode treeNode)
        {
            RadTreeNode topTreeNode = treeNode;
            if (topTreeNode.Parent != null)
            {
                topTreeNode = GetTopNode(topTreeNode.Parent);
            }
  
            return topTreeNode;
        }
  
        private void Form1_Load(object sender, EventArgs e)
        {
            radTreeView1.Nodes.Clear();
            RadTreeNode root = new RadTreeNode("root");
            root.CheckType = CheckType.CheckBox;
            for (int x = 1; x < 4; x++)
            {
                RadTreeNode main = new RadTreeNode("Main " + x.ToString());
                main.CheckType = CheckType.CheckBox;
                for (int y = 1; y < 4; y++)
                {
                    RadTreeNode sub = new RadTreeNode("Sub " + y.ToString());
                    sub.CheckType = CheckType.CheckBox;
                    main.Nodes.Add(sub);
                }
                main.Expanded = false;
                root.Nodes.Add(main);
            }
            root.Expanded = true;
            radTreeView1.Nodes.Add(root);
        }
  
    }
}

Stefan
Telerik team
 answered on 30 Sep 2014
11 answers
1.2K+ views
The telerik radgridview takes a long time to load all records.

  Dim strProp As String = "Select * from " & ViewName
  Dim daProp As New OleDb.OleDbDataAdapter(strProp, conNFAD_NEW)
  Dim dsProp As New DataSet
  daProp.Fill(dsProp, "dtProp")
  rgvMain.DataSource = dsProp.Tables("dtProp")

(rgvMain) being the radgridview

The query returns 31 000 records (8 columns). It takes about 10 seconds to load.

--------------

I tried instead of doing "select * from"  to do a "select top 500". But when you filter the radgridview it filters the 500 records it returned form the query not the 31 000. which is correct.

But:

Is there a way to re-query the grid when a filter is applied so that it would return the top 500 records with the applied filter.

Thanks,

Goran Djuric

George
Telerik team
 answered on 30 Sep 2014
5 answers
207 views
I have a date coming from the database in the format yyyymmdd.  I would like it to display in the drop down as mm/dd/yyyy.  I thought I could accomplish this with the FormatString, but as I'm finding out...not so much.  Anybody got any ideas how to accomplish this?

Thanks
Steve
Dimitar
Telerik team
 answered on 29 Sep 2014
2 answers
521 views
Hi - I'm trying to print silently to the default printer though either the the radPDFViewerNavigator print button or the radPDFViewer default context menu.

For the radPDFViewerNavigator print button click event, I have the following:
me.RadPdfViewer1.Print(False)

This causes the document to print directly to the default printer but then right after that it still brings up the print dialog box.  Is there any way to keep the dialog box from showing?

As for the context menu print option, I can't seem to find a way to get the click event of this in order to override showing the print dialog box.

Any assistance on this will be greatly appreciated.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 29 Sep 2014
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Form
Chart (obsolete as of Q1 2013)
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
Wizard
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
NavigationView
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
SplashScreen
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?