Telerik Forums
UI for WinForms Forum
7 answers
312 views

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; }
    }
}
Nadya | Tech Support Engineer
Telerik team
 answered on 04 Mar 2021
1 answer
129 views

     Hello,

When using a VisualStudio2012Dark themed GridView with ColumnHeader, GroupPanel, and AddNewRow turned off, the top border of the grid is missing. It only appears with a border width that is greater than 1.

To reproduce:

  1. Drop a RadGridView into a new form
  2. Change the form's theme to VisualStudio2012DarkTheme. Apply to all controls.
  3. Add the following to the form's load event
RadGridView1.ShowColumnHeaders = False
RadGridView1.ShowGroupPanel = False
RadGridView1.AllowAddNewRow = False
 
RadGridView1.Columns.Add("1")
RadGridView1.Columns.Add("2")
RadGridView1.Columns.Add("3")
 
RadGridView1.Rows.Add(1, 2, 3)
RadGridView1.Rows.Add(4, 5, 6)
RadGridView1.CurrentRow = Nothing
 
RadGridView1.TableElement.DrawBorder = True
RadGridView1.TableElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder
RadGridView1.TableElement.BorderGradientStyle = Telerik.WinControls.GradientStyles.Solid
RadGridView1.TableElement.BorderColor = Color.Yellow
RadGridView1.TableElement.BorderWidth = 1

 

I'm not sure if that is part of the theme, but either way I can't seem to add a single pixel border to the top.

 

Also, the description for TableElement.BorderWidth is incorrect; it says it is for the left border.

 

This is for R3 2018.

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 04 Mar 2021
9 answers
112 views

hi

i can change font FilterPopup but font "available filers" not changes

This section is marked in the photo below

 

moj
Top achievements
Rank 1
 answered on 04 Mar 2021
2 answers
173 views

hi

i tranaslte all word in  grid but "filter dialog" not ranslates

This section is marked in the photo below

 

moj
Top achievements
Rank 1
 answered on 27 Feb 2021
4 answers
206 views

Hello

I am trying to write a customEditor for a gridview to handle "rapid" data entry for grade values.

The grade values can be from 0 to 10 in steps of 0.5 (valid values are, for instance, 4 or 4.5, but not 4.1)
I wish to be able to type in the grades on the numerical keypad and on the main keyboard
where:typing a single character numeric value sets the value typed
and typing CTRL-num value sets the "halfed grade" (ex: type CTRL-4 for obtaining 4.5)
furthermoreI need to have the cursor positioned to the cell below imediately after the entry validation

The columns are currently text columns but could be numerical columns

I have tried using the followind code and Custom Editor:

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

    Private Sub gvMark_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles gvMark.EditorRequired
        If e.EditorType Is GetType(RadTextBoxEditor) Then
            e.EditorType = GetType(MarkEditor)
        End If
    End Sub

Public Class MarkEditor
    Inherits RadTextBoxEditor
    Public Property Value As Object
        Get
            Dim Editor As RadTextBoxEditorElement = CType(EditorElement, RadTextBoxEditorElement)
            Return Editor.Text
        End Get
        Set(value As Object)
            Dim Editor As RadTextBoxEditorElement = CType(EditorElement, RadTextBoxEditorElement)
            If value IsNot Nothing Then
                Editor.Text = Convert.ToString(value)
            Else
                Editor.Text = ""
            End If
        End Set
    End Property
    Public Overrides Sub BeginEdit()
        MyBase.BeginEdit()
        Me.EditorElement.Focus()
        Dim EditorElement As RadTextBoxEditorElement = CType(Me.EditorElement, RadTextBoxEditorElement)
        AddHandler EditorElement.KeyDown, AddressOf Element_KeyDown
    End Sub
    Public Overrides Function EndEdit() As Boolean
        MyBase.EndEdit()
        Me.EditorElement.Focus()
        Dim EditorElement As RadTextBoxEditorElement = CType(Me.EditorElement, RadTextBoxEditorElement)
        RemoveHandler EditorElement.KeyDown, AddressOf Element_KeyDown
        Return MyBase.EndEdit
    End Function
    Private Sub Element_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
        Try
            Dim KeyChar As String = fromKeyCode(e.KeyCode)
            If Not e.Control Then
                Value = KeyChar
            Else
                Value = KeyChar & ".5"
            End If
        Catch ex As Exception

        End Try
    End Sub

        Public Function fromKeyCode(KeyCode As Integer) As String
            'returns the caracters 0..9 for Keyboard Keys 0..9 and NumPadKeys 0..9 and "*" from NumPad "Multiply"
            Try
                If KeyCode >= 48 And KeyCode <= 57 Then '0..9 Keyboard
                    Return (KeyCode - 48)
                ElseIf KeyCode >= 96 And KeyCode <= 105 Then '0..9 NumPad
                    Return (KeyCode - 96)
                ElseIf KeyCode = 106 Then '* NumPad
                    Return "*"
                Else
                    Return ""
                End If
            Catch ex As Exception
                Return ""
            End Try
        End Function

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

I have a strange result (same result when using the keyboard or the numeric pad)

1. if I type a single numeric value -> it is displayed twice in the cell, i.e.if I type 4 I see 44 and the cursor is in the middle of the two characters

2. if I type CTRL-4 I get the desired 4.5 string in the cell

3. I have tried to add a sendkeys.send(vbcr) at different places (valueChanged, CellvalueChanged events unsuccessfully) to move the focus to the cell below

(Ultimately I'll have to do more advanced data validation based on other criterias)

Thanks in advance for any suggestion

Best Regards

pierre-jean
Top achievements
Rank 1
Veteran
Iron
 answered on 26 Feb 2021
1 answer
232 views

Hallo Admin,

here I have a problem when I want to give a line to the label series on the ChartView (DonutSeries),
in this case I want to label the line always up, even though the position of the chart data is below
which I have created is in the image (Chart_No.png)

and I want to make like the image (Chart_Yes.png)

this is the method that i have created.

private void DrawRadChartViewDonutChart(RadChartView p_oRadChart)
        {
            p_oRadChart.View.Margin = new Padding(20); //set pie padding
            p_oRadChart.AreaType = ChartAreaType.Pie; //set to pie chart type
            p_oRadChart.Series.Clear();

            #region Config New Chart Series
            Telerik.WinControls.UI.DonutSeries smartPie = new Telerik.WinControls.UI.DonutSeries();
            smartPie.Name = "Series";
            smartPie.InnerRadiusFactor = 0.45f; //setting inner radious doughnut so it can change as Doughnut Chart
            smartPie.LabelMode = PieLabelModes.Horizontal;
            smartPie.ShowLabels = true; //show label text
            smartPie.DrawLinesToLabels = true; //show label line connector

            smartPie.LinesToLabelsColor = Color.FromArgb(197, 156, 97); //set label line connector color
            smartPie.SyncLinesToLabelsColor = false; //set true if we want to set label line color the same as series color
            smartPie.Size = new Size(200, 200);
            //set angle range starting position
            AngleRange range = smartPie.Range;
            range.StartAngle = 250;
            smartPie.Range = range;

            #endregion

            #region Generate Data
            

            List<DataChart> lData = new List<DataChart>();
            lData.Add(new DataChart("Savings", 30));
            lData.Add(new DataChart("Deposit", 15));
            lData.Add(new DataChart("Credit", 15));
            lData.Add(new DataChart("BancaAssurance", 10));
            lData.Add(new DataChart("MutualFund", 10));
            lData.Add(new DataChart("Jasa Giro", 20));
            #endregion

            //add slice area
            foreach (DataChart d in lData)
            {
                PieDataPoint point = new PieDataPoint(Convert.ToDouble(d.Value), d.Name);
                point.Label = d.Name.ToUpper();
                point.Label = string.Format("{0} | {1}%{2}{3} {4}", d.Name.ToUpper(), d.Value, Environment.NewLine, "IDR", Convert.ToDouble(d.ValueRp).ToString("N0"));
                smartPie.DataPoints.Add(point);
            }
            p_oRadChart.Series.Add(smartPie);

            #region Setting Series Slice Color
            p_oRadChart.Series[0].Children[0].BackColor = Color.FromArgb(193, 152, 105);
            p_oRadChart.Series[0].Children[1].BackColor = Color.FromArgb(207, 175, 140);
            p_oRadChart.Series[0].Children[2].BackColor = Color.FromArgb(221, 198, 173);
            p_oRadChart.Series[0].Children[3].BackColor = Color.FromArgb(235, 221, 206);
            p_oRadChart.Series[0].Children[4].BackColor = Color.FromArgb(193, 152, 105);
            p_oRadChart.Series[0].Children[5].BackColor = Color.FromArgb(207, 175, 140);
            p_oRadChart.Series[0].IsVisible = true;
            #endregion
        }

please help, thank you

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 26 Feb 2021
1 answer
240 views

Please provide a basic example (or a link to) of how to use the DesktopAlertManager.

I want to be able to display multiple alerts and stack them if they appear at the same time.

 

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 26 Feb 2021
3 answers
156 views

We are in the early process of converting from VB to C#. Before we convert, we are turning on Option Strict, one project at a time. I got the following Late Binding error on a RadDropDownList.DataSource. DataSource is deemed as an object (line 09 & 14), which is what is throwing the error, but not sure how to repair this. (error screenshot attached)

01.Public Shared Function IndexOfKeyOrValue(ByRef ddl As RadDropDownList, ByVal myString As String, ByVal LocateKey As Boolean) As Integer
02.    ' What I would like to do is pass any control to this function, see if it has a datasource and then do the rest.
03.    ' Use the TypeOf to determine the type of the control
04.    'AddEvent("IndexOfKeyOrValue Looking For: " & myString & " in " & ddl.Name)
05.    Try
06.        For xx As Integer = 0 To ddl.Items.Count
07.            'AddEvent(ddl.DataSource(xx).Key & "  " & ddl.DataSource(xx).Value)
08.            If LocateKey Then
09.                If ddl.DataSource(xx).Key = myString Then
10.                    'AddEvent("---- Index Found = " & xx)
11.                    Return xx
12.                End If
13.            Else
14.                If ddl.DataSource(xx).Value = myString Then
15.                    'AddEvent("---- Index Found = " & xx)
16.                    Return xx
17.                End If
18.            End If
19. 
20.        Next
21.    Catch ex As Exception
22.        ' AddEvent("---- NOT FOUND Index = -1")
23.        Return -1
24.    End Try
25.End Function  'IndexOfKeyOrValue
Nadya | Tech Support Engineer
Telerik team
 answered on 25 Feb 2021
4 answers
349 views

Hello team,

 

i got a RadRibbonBar, with RibbonBarGroups in it and one of the RadRibbonBarGroups contains a RadTextBoxElement. Im currently failing at the following goal:

- i want to catch the moment when the textbox looses the mouse focus.

Im using the MouseDown event to initiate the user interaction with the textbox and now i want an oposite to that, so that i can recognize if the user has "mousedowned" any other control on the screen.

I tried the MouseLeave event which seems not to be the totaly right thing, but still better than nothing - this even fires from time to time but i cant tell on which exact condition. Moving the mouse away from the textbox does not always trigger it.

The MouseLostCapture event - not sure if its right at all - didnt trigger even once.

Please tell what event should i use for my need?

 

Thank you!

 

 

 

 

 

Nadya | Tech Support Engineer
Telerik team
 answered on 25 Feb 2021
8 answers
544 views
Hi,
I have a need to create a list of items from a grid using only the rows that are displayed (not filtered).  I tried to use the RowInfo.IsVisible property but it seems that all rows "IsVisible" is set to true even if the row is not visible due to it being filtered out.

The scenario is; The user creates a filter on a gird and then clicks a button (or whatever to trigger an event) and then the program needs to be able to get values from just the un-filtered rows.

Does anyone know how this can be done?

Thanks,
Mike B.

Update:
After more testing, the IsVisible does seem to be set to false for rows that are filtered out.
Sorry for "jumping the gun".

Mike B
Pioter
Top achievements
Rank 1
 answered on 25 Feb 2021
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)
Chart (obsolete as of Q1 2013)
Form
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
Diagram, DiagramRibbonBar, DiagramToolBox
GanttView
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
ProgressBar
CheckedDropDownList
TrackBar
MessageBox
Rotator
SpinEditor
StatusStrip
CheckedListBox
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
DataEntry
ScrollablePanel
ScrollBar
WaitingBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Barcode
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
NavigationView
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
Licensing
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?