Telerik Forums
UI for WinForms Forum
5 answers
529 views
I am experimenting with an application that will give me CPU Usage, Memory Usage, and I want to expand it from there. Right now it goes to two Text Boxes. I combined it into the first text box 

How do I display each value in two GridView Columns?

Here is what I have now;

using System;
using System.Diagnostics;
using System.Data;
using System.Windows.Forms;
 
namespace MemOV
{
    public partial class FrmMain : Form
    {
        private PerformanceCounter cpuCounter;
        private PerformanceCounter ramCounter;
 
        public FrmMain()
        {
            InitializeComponent();
            InitializeCpuCounter();
            InitializeRamCounter();
            updateTimer.Start();
        }
 
        private void UpdateTimerTick(object sender, EventArgs e)
        {
            this.textBox1.Text = "CPU Usage: " + Convert.ToInt32(cpuCounter.NextValue()).ToString() + "%" + "  | " + "Memory Usage: " + Convert.ToInt32(ramCounter.NextValue()).ToString() + "Mb";
            this.textBox2.Text = Convert.ToInt32(ramCounter.NextValue()).ToString() + "Mb";
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        private void InitializeCpuCounter()
        {
            cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
        }
 
        private void InitializeRamCounter()
        {
            ramCounter = new PerformanceCounter("Memory", "Available MBytes", true);
        }
    }
}


Dimitar
Telerik team
 answered on 26 Sep 2014
3 answers
80 views
Hello,

I develop stock manager application for my company

I've a error message  converter can't convert

With VS2013 DataGridView, it's work but not with RadGridView

My code :

Private Sub MasterTemplate_CellClick(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellClick
        If e.ColumnIndex = 0 Then
            Dim oCell As GridViewCellInfo = DirectCast(RadGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex), GridViewCellInfo)
            If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
                Dim oImage As Image = Image.FromFile(OpenFileDialog1.FileName)
                oCell.Value = resizeImage(oImage, 48, 48)
            Else
                Dim oResult As DialogResult = MessageBox.Show("Voulez-vous supprimer l'icône associée à ce produit ?", "Icône du produit", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                If oResult = Windows.Forms.DialogResult.Yes Then oCell.Value = Nothing
            End If
        End If
End Sub

Private Function resizeImage(ByVal oImage As Image, iWidth As Integer, iHeight As Integer) As Image
        Dim oSource As Bitmap = New Bitmap(oImage)
        Dim dScale As Double = oSource.Height / oSource.Width
        Dim oDest As New Bitmap(iWidth, iHeight)
        Dim gDest As Graphics = Graphics.FromImage(oDest)
        With gDest
            .InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
            .SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
            .CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
            .DrawImage(oSource, 0, 0, oDest.Width, oDest.Height)
            Return oDest
        End With
End Function





Dimitar
Telerik team
 answered on 26 Sep 2014
1 answer
103 views
Hi,

I use telerik Version 2011.1.411.2 (Runtime 2.0.50727).

I added a new colum in my database schema (for information double d_Value),
and I want that the data that is already memorized in database take value "1.0" not "0.0".

Can you explain how can I do ?

In advance, Thanks,
Richard.
Doroteya
Telerik team
 answered on 26 Sep 2014
5 answers
120 views
Hello to all!

I've a GridViewMaskBoxColumn, where float are displayed using the exponental notation.  When I try to change a cells value, I can put the wished values, but when I leave the editor, the application crashs (even if I put only a '0')

The crash happens immediately after leaving the 'CellEndEdit'.

What went wrong in my source?

Thanks for your help!




   
   System.NullReferenceException wurde nicht behandelt.
  Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
  Source=Telerik.WinControls.UI
  StackTrace:
       bei Telerik.WinControls.UI.RegexMaskTextBoxProvider.KeyDown(Object sender, KeyEventArgs e)
       bei Telerik.WinControls.UI.RadMaskedEditBoxElement.TextBoxItem_KeyDown(Object sender, KeyEventArgs e)
       bei System.Windows.Forms.KeyEventHandler.Invoke(Object sender, KeyEventArgs e)
       bei Telerik.WinControls.RadItem.OnKeyDown(KeyEventArgs e)
       bei Telerik.WinControls.UI.RadTextBoxItem.TextBoxControl_KeyDown(Object sender, KeyEventArgs e)
       bei System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
       bei System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       bei System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       bei System.Windows.Forms.Control.WmKeyChar(Message& m)
       bei System.Windows.Forms.Control.WndProc(Message& m)
       bei System.Windows.Forms.TextBoxBase.WndProc(Message& m)
       bei System.Windows.Forms.TextBox.WndProc(Message& m)
       bei Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
       bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.Run(Form mainForm)
       bei Maxsyma.PLCExplorer.Program.Main() in e:\...\SourceCode\Regex\Program.cs:Zeile 40.
  InnerException:



Here is my code:

private void InitializeGrid()
{
..
    newColumn = new GridViewMaskBoxColumn();    // for float
    newColumn.Name = "Gleitpunkt";
    newColumn.TextAlignment = ContentAlignment.MiddleRight;
    newColumn.Width = 60;
    newColumn.HeaderText = "Gleitpunkt";
    newColumn.FormatString = "{0:0.000000e0}";
    this.radGridViewCapture.Columns.Add(newColumn);
..
}

private void CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
    {
        RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
        spinEditor.EditorElement.Alignment = ContentAlignment.MiddleCenter;
        spinEditor.EditorElement.StretchVertically = false;
        this.radGridViewCapture.CurrentCell.Alignment = ContentAlignment.MiddleCenter;
    }
}

private void CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
    {
        RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
        if (e.Column.Name == ColumnName.Names[ColumnName.ResultGleitpunkt])
        {
            spinEditor.MaskTextBox.MaskType = MaskType.Regex;
            spinEditor.MaskTextBox.Mask = "[-+]?([0-9]*[,.])?[0-9]+([eE][-+]?[0-9]+)?"; // e.g. 123.4e+5
        }
    }
}

private void CellEndEdit(object sender, GridViewCellEventArgs e)
{
    if (e.Column.Name == "Gleitpunkt")
    {
        float myNewValue = float.Parse(e.Row.Cells[e.ColumnIndex].Value.ToString());
        
        // myNewValue is e.g. 0 or  123  or  123.4e-88 and is correct so far
    }
}            




George
Telerik team
 answered on 25 Sep 2014
3 answers
187 views
I  have  Telerik winforms Q3 2011 SP1 version. I want to print a gridview but I didn't find RadPrintDocument. Is there any way gridview printing.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 25 Sep 2014
2 answers
456 views
I need to disable the radbutton just before the click event is fired, and finally resume its enabled state after the click event.
I tried to create a property like this in my CustomRadButton:
/// <summary>
        /// On click event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnClick(EventArgs e)
        {
            if (this.multiClickAccepted)
                base.OnClick(e);
            else
            {
                //if the multiclick is disabled (as default) disable the button before raise any event
                this.temporaryEnabled = this.Enabled;
                base.Enabled = false;
                base.OnClick(e);
                base.Enabled = (bool)this.temporaryEnabled;
                this.temporaryEnabled = null;
                //after the reactivation look for any binding to restore the correct button state
                if (this.DataBindings != null)
                {
                    foreach (System.Windows.Forms.Binding b in this.DataBindings)
                    {
                        if (b.PropertyName.Equals("Enabled"))
                            b.ReadValue();
                    }
                }
            }
        }

But in debug I found out that the base.OnClick(e); event is asynchronous.

Can you suggest something to solve my problem?

Thanks
Dimitar
Telerik team
 answered on 25 Sep 2014
3 answers
111 views
I'm using the Entity Framework with a Data Source and I would like to be able to drag and drop a field and have it be edited with a RadTextBox. When I go to customize, I see 15 Telerik controls in the list, but not RadTextBox, why not and what can I do to make the Telerik controls the default when using visual data sources. I click on the field, then Customize... and I have "Data UI Customization" selected with data type "String".

Thanks.

-John Baima

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 24 Sep 2014
1 answer
436 views
Hi all,
I've got a column containing Minutes as an integer.  I'm trying to sum this and format it as a Time Span like hh:mm (no seconds or days).
I'm not too familiar with the AggregateExpression strings.
Is there a way to cast that aggregate into a timespan, either during or after the sum from within the expression?

I've got a group summary and a grand total that this needs to appear on.

 
summaryItem.Name = "TimeWorked"
summaryItem.AggregateExpression = "SUM(MinutesWorked)"
summaryItem.FormatString = "{0:hh}:{0:mm} = {0}"

TimeWorked column - string value formatted by database in hh:mm format
MinutesWorked column - integer value  - need Timespan.FromMinutes(...)
FormatString - the ' = {0}' at the end is for checking the value of the sum.

Currently, for example:     hh:mm = 2239
Hoping for:                        37:19 = 2239

Or is tackling this in the expression not possible? 
Or maybe as it loads into the column?
I've tried/am trying events also but hoping the 3 lines of code is do-able...

Thanks

Dimitar
Telerik team
 answered on 24 Sep 2014
1 answer
154 views
Is it possible to have a single line rich text box without showing scrollbars?

I ideally want to use it for the user to enter a hyperlink and click on it to go to that web page.

Thanks

Andez
Dimitar
Telerik team
 answered on 24 Sep 2014
5 answers
1.0K+ views
how to remove items from listview?
i tried this pieces of code but i got an exception
foreach (ListViewDataItem eachItem in radListView1.SelectedItems)
            {
                radListView1.Items.Remove(eachItem);
            } 

my exception is Collection was modified; enumeration operation may not execute.
Stefan
Telerik team
 answered on 24 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
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
CollapsiblePanel
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
Styling
Barcode
PopupEditor
RibbonForm
TaskBoard
Callout
NavigationView
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Security
LocalizationProvider
Dictionary
SplashScreen
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?