Telerik Forums
UI for WinForms Forum
2 answers
98 views

I use RadGridView and have custom cell element.

I set row height = 300.

For custom cell element, i use RadHostItem to create childe
Ex: 

protected override void CreateChildElements()
       {
           base.CreateChildElements();
 
           var label = new Label();
           label.Text = "test";
           var layout = new TableLayoutPanel();
           layout.ApplyDefaultStyles("Master layout");
           layout.Dock = DockStyle.Fill;
           layout.ColumnCount = 1;
           layout.RowCount = 1;
           layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
           layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
           layout.Controls.Add(label, 0, 0);
           layout.AutoScroll();
 
           var child = new RadHostItem(layout) { AutoSizeMode = RadAutoSizeMode.Auto};
           Children.Add(child);
       }

 

Result (see the picture in attachments)

Thanks and kind regards

Paul

 

Hristo
Telerik team
 answered on 10 May 2017
2 answers
140 views

Hi,

 

I have inherited a scheduler like this:

 

Public Class Test
    Inherits RadScheduler

End Class

 

All works very fine. But i have trouble with themes.

I added a application-wide theme like this:

   Dim visualStudio2012LightTheme1 = New Themes.VisualStudio2012LightTheme()
   ThemeResolutionService.ApplicationThemeName = visualStudio2012LightTheme1.ThemeName

 

The SchedulerNavigator (also in my Form) changed its style, but my inherited scheduler do not. The scrollbar on the right side has the new theme, and the appointment form and all other "subcontrols".

More details in screenshot.

 

Can you help me?

 

 

Sascha
Top achievements
Rank 1
 answered on 10 May 2017
2 answers
148 views
Currently if you select the control by clicking on it - it makes active editable part of the date exactly where you clicked (for ex. yyyy part of the mm/dd/yyyy date). Users want to have selection  to be always in the start of the date not tied to place where they clicked . How could be selection be moved to the first part of the date (mm part in our case)?
Vladimir
Top achievements
Rank 1
 answered on 10 May 2017
2 answers
356 views

Hello,

I tried to bring our scatter plot chart feature from our website to our winform application.

I tried to use chartview to implement this feature, then I cannot find an option to add title into x-axis and y-axis.

So what should I do to add title into x-axis and y-axis?

Attachment #1 is in website version

Attachment #2 is in winform version

Regard,

Paul

 

Paul
Top achievements
Rank 1
 answered on 10 May 2017
5 answers
235 views

Hello,

I tried to create a scatter plot chart just like attachment 1. Then I tried to show checkbox to show/ hide it's series points.

In this case, the long labels have been overlap and I tried to style for legend items to make the labels is next to the checkbox but I cannot find the solution.

So what should I do to do like that?

Regard,

Paul

Paul
Top achievements
Rank 1
 answered on 10 May 2017
5 answers
219 views

Hello,

I tried to update icons for: options, pin and close buttons just like attachment #1 then the background of 3 buttons always white although I tried many ways to change it (the result is attachment #2).

So what should I do to change these 3 buttons's icon?

3 sample icons have been attached in the attachment section

Regard,

Paul

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 10 May 2017
0 answers
99 views

How to firing enter key only on column 1 or 2 ...

have this code ... 

    Private Sub GridList_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GridList.KeyDown
        If e.KeyCode = Keys.Enter Then
                 Msgbox "Enter KeyPress" 

       End If

    End Sub

Hengky
Top achievements
Rank 1
Veteran
 asked on 10 May 2017
2 answers
545 views

Working with (trial) version 2017.2.502.40... 

I'm trying to build a simple editor, but request is that users should be allowed to change only very few formatting details in the document: essentially

- just set bold on / off

- format text as list

- and set paragraph alignment

I've tried to customise the provided ribbon, but if I hide tabs, this results in holes between the remaining tabs.

I've been looking for a sample with a custom toolbar them, but cannot find any.

 

Any hints

TIA

Ralitsa
Telerik team
 answered on 09 May 2017
1 answer
267 views

 

cannot create an instance of

telerik.wincontrols.ui.gridviewdatacolumn because it is an abstract class

Dimitar
Telerik team
 answered on 09 May 2017
6 answers
180 views

Hi,

I use GridView and custom cell element, however it is wrong to display, please help me to resolve it!

My code and video demo below
+ Change page size -> scroll -> change form size to normal -> hide to task bar -> re-open from task bar -> wrong

+ video: https://youtu.be/8ytr-AFMzRc
+ my code:

public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        public RadForm1()
        {
            InitializeComponent();
            this.ThemeName = "TelerikMetro";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
 
            var layer1 = new TableLayoutPanel();
 
            layer1.Dock = DockStyle.Fill;
            layer1.Location = new Point(0);
            layer1.Margin = new Padding(0);
            layer1.ColumnCount = 2;
            layer1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 30F));
            layer1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            layer1.RowCount = 2;
            layer1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28F));
            layer1.RowStyles.Add(new RowStyle(SizeType.Absolute, 0F));
            layer1.AutoSize = true;
 
            var label = new RadLabel();
            label.Dock = DockStyle.Fill;
            label.Text = @"Test grid view";
            label.ThemeName = "TelerikMetro";
 
            layer1.Controls.Add(label, 0, 0);
            layer1.SetColumnSpan(label, 2);
 
            var radGridView1 = new RadGridView
            {
                Dock = DockStyle.Fill,
                AutoGenerateColumns = false,
                AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill,
                ThemeName = "TelerikMetroTouch",
                AllowDeleteRow = false,
                AllowAddNewRow = false,
                // AllowEditRow = false,
                EnableGrouping = false,
                EnablePaging = true,
                Margin = new Padding(5, 10, 5, 10),
                PageSize = 10,
                AllowColumnHeaderContextMenu = false,
                AllowRowHeaderContextMenu = false
            };
 
            radGridView1.CreateCell += RadGridView1_CreateCell;
 
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 1", "Column 1")
            {
                HeaderText = @"",
                ReadOnly = true,
                Width = 280,
                AllowSort = false,
                AllowResize =  false,
                AllowReorder = false
            });
 
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 2", "Column 2"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 3", "Column 3"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 4", "Column 4"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 5", "Column 5"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 6", "Column 6"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 7", "Column 7"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 8", "Column 8"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 9", "Column 9"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 10", "Column 10"));
            radGridView1.Columns.Add(new GridViewMaskBoxColumn("col 11", "Column 11"));
 
            RenderData(radGridView1);
 
            GridViewUpdateHeight(radGridView1);
 
            var layer2 = new TableLayoutPanel();
 
            layer2.Dock = DockStyle.Fill;
            layer2.Location = new Point(0);
            layer2.Margin = new Padding(0);
            layer2.ColumnCount = 1;
            layer2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            layer2.RowCount = 1;
            layer2.RowStyles.Add(new RowStyle(SizeType.Absolute, radGridView1.Height));
            layer2.AutoSize = true;
 
            layer2.Controls.Add(radGridView1, 0, 0);
 
            layer1.Controls.Add(layer2, 1, 1);
            layer1.RowStyles[1].SizeType = SizeType.AutoSize;
 
            Controls.Add(layer1);
        }
 
        private void GridViewUpdateHeight(RadGridView grid)
        {
            var actualRowCount = grid.RowCount < grid.PageSize ? grid.RowCount : grid.PageSize;
            var height = actualRowCount * 40;
 
            if (grid.AllowAddNewRow && !grid.ReadOnly)
            {
                height += grid.MasterView.TableAddNewRow.GetActualHeight(grid.TableElement);
            }
            if (grid.EnableFiltering)
            {
                height += grid.MasterView.TableFilteringRow.GetActualHeight(grid.TableElement);
            }
            if (grid.ShowColumnHeaders)
            {
                height += grid.MasterView.TableHeaderRow.GetActualHeight(grid.TableElement);
            }
            if (grid.EnablePaging)
            {
                height += 50;
            }
            height += 20; // horizontal scroll bar height
 
            grid.Height = height;
        }
 
        private void RenderData(RadGridView radGridView1)
        {
            for (int k = 0; k < 100; k++)
            {
                GridViewDataRowInfo rowInfo = new GridViewDataRowInfo(radGridView1.MasterView);
                rowInfo.Height = 40;
 
                for (int i = 1; i < radGridView1.Columns.Count; i++)
                {
                    rowInfo.Cells[i].Value = "Row: " + k + " - column: " + i;
                }
 
                radGridView1.Rows.Add(rowInfo);
            }
        }
 
        private void RadGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
        {
            if (e.Row is GridFilterRowElement)
                return;
 
            if (e.Column.Index == 0)
            {
                if (e.Row is GridTableHeaderRowElement && e.CellType == typeof(GridHeaderCellElement))
                {
                    e.CellElement = new PageSizeDropdownHeaderCellElement(e.Column, e.Row);
                }
 
                if (e.Row is GridDataRowElement)
                {
                    var actionCellElement = new ActionCellElement(e.Column, e.Row);
                    e.CellElement = actionCellElement;
                }
            }
        }
    }
 
    public sealed class PageSizeDropdownHeaderCellElement : GridHeaderCellElement
    {
        public PageSizeDropdownHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row)
        {
            TextAlignment = ContentAlignment.TopCenter;
            Alignment = ContentAlignment.TopCenter;
            AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
        }
 
        private RadDropDownListElement _dropDownListElement;
 
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
            if (_dropDownListElement?.DataSource == null)
            {
                _dropDownListElement = new RadDropDownListElement();
                _dropDownListElement.BindingContext = new BindingContext();
                _dropDownListElement.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
 
                _dropDownListElement.Items.Clear();
                _dropDownListElement.Items.Add(new RadListDataItem("10", 10) { Selected = true });
                _dropDownListElement.Items.Add(new RadListDataItem("25", 25));
                _dropDownListElement.Items.Add(new RadListDataItem("50", 50));
                _dropDownListElement.Items.Add(new RadListDataItem("100", 100));
                _dropDownListElement.Items.Add(new RadListDataItem("All", -1));
 
                _dropDownListElement.Margin = new Padding(15, 0, 0, 0);
                _dropDownListElement.StretchHorizontally = true;
                _dropDownListElement.NotifyParentOnMouseInput = false;
                _dropDownListElement.Popup.MouseClick -= Popup_MouseClick;
                _dropDownListElement.Popup.MouseClick += Popup_MouseClick;
 
                _dropDownListElement.PopupClosed -= _dropDownListElement_PopupClosed;
                _dropDownListElement.PopupClosed += _dropDownListElement_PopupClosed;
 
                _dropDownListElement.FitToSizeMode = RadFitToSizeMode.FitToParentPadding;
                _dropDownListElement.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
                _dropDownListElement.AutoSize = true;
 
                this.Children.Add(_dropDownListElement);
            }
        }
 
        private RadListVisualItem _elementUnderMouse;
 
        private void Popup_MouseClick(object sender, MouseEventArgs e)
        {
            _elementUnderMouse = _dropDownListElement.Popup.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
        }
 
        private void _dropDownListElement_PopupClosed(object sender, RadPopupClosedEventArgs args)
        {
            if (_elementUnderMouse == null)
            {
                return;
            }
            if (_dropDownListElement.SelectedIndex == -1)
                return;
 
            var pageSize = Convert.ToInt32(_elementUnderMouse.Data.Value);
 
            if (pageSize == -1)
            {
                pageSize = GridControl.RowCount < 1000 ? 1000 : GridControl.RowCount;
            }
 
            // Backup selected pageSize and re-select when re-render grid view
            RowInfo.Tag = pageSize;
 
            GridControl.PageSize = pageSize;
            _elementUnderMouse = null;
        }
 
        protected override void SetContentCore(object value)
        {
            if (_dropDownListElement != null && RowInfo?.Tag != null)
            {
                this._dropDownListElement.SelectedValue = (int)RowInfo.Tag;
            }
        }
 
        public override bool IsCompatible(GridViewColumn data, object context)
        {
            return context is GridTableHeaderRowElement;
        }
 
        protected override Type ThemeEffectiveType => typeof(GridHeaderCellElement);
    }
 
    public sealed class ActionCellElement : GridDataCellElement
    {
        #region Public Delegates
 
        public delegate void EventHandler(object sender, EventArgs e);
 
        #endregion Public Delegates
 
        #region Public Events
 
        public event EventHandler OnSelectedRecord;
 
        public event EventHandler OnUnSelectedRecord;
 
        #endregion Public Events
 
        #region Private Fields
 
        public GridViewCheckBoxElement CheckBoxElement;
        public RadButtonElement BtnFlag;
        public RadButtonElement BtnTimeCircle;
 
        #endregion Private Fields
 
        private readonly RadOffice2007ScreenTipElement _screenTip;
 
        #region Public Constructors
 
        public ActionCellElement(GridViewColumn column, GridRowElement row) : base(column, row)
        {
            Name = "ActionCell_" + RowIndex;
            Text = string.Empty;
 
            _screenTip = new RadOffice2007ScreenTipElement();
            _screenTip.MainTextLabel.Padding = new Padding(2);
            _screenTip.CaptionLabel.Padding = new Padding(2);
            _screenTip.CaptionLabel.Text = @"<html><color=red>Created Date";
            BtnTimeCircle.ScreenTip = _screenTip;
        }
 
        #endregion Public Constructors
 
        public void SetFlagImage(GridViewRowInfo rowInfo = null)
        {
            if (rowInfo != null)
            {
                RowInfo = rowInfo;
            }
        }
 
        #region Protected Methods
 
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            SizeF size = base.ArrangeOverride(finalSize);
            RectangleF clientRect = GetClientRectangle(finalSize);
            float marginX = 4;
            float width = clientRect.Width - (Children.Count + 1) * 4;
            foreach (RadElement element in this.Children)
            {
                var btnWidth = width / Children.Count;
                element.Arrange(new RectangleF(
                        marginX,
                        clientRect.Top + 2,
                        btnWidth,
                        clientRect.Height - 4));
                marginX += btnWidth + 4;
            }
            return size;
        }
 
        protected override void CreateChildElements()
        {
            BtnFlag = new GridViewButtonElement(GetChildElementName("btnFlag"), Resources.USDA_icon_RedFlag);
 
            BtnTimeCircle = new GridViewButtonElement(GetChildElementName("btnTimeCircle"), Resources.USDA_icon_TimeCircle);
 
            CheckBoxElement = new GridViewCheckBoxElement(GetChildElementName("chkBoxItem"));
            CheckBoxElement.ToggleState = ToggleState.Off;
 
            CheckBoxElement.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
            BtnTimeCircle.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
            BtnFlag.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
 
            Children.Clear();
            Children.Add(CheckBoxElement);
            Children.Add(BtnFlag);
            Children.Add(BtnTimeCircle);
        }
 
        #endregion Protected Methods
 
        #region Private Methods
        private string GetChildElementName(string elementName)
        {
            return elementName;
        }
 
        #endregion Private Methods
    }
 
    public sealed class GridViewCheckBoxElement : RadCheckBoxElement
    {
        public bool MultiSelect { get; set; }
 
        public GridViewCheckBoxElement(string name, string text = null)
        {
            DisplayStyle = DisplayStyle.Text;
            Name = name;
            Text = text;
            Alignment = ContentAlignment.MiddleCenter;
            ShowBorder = false;
            BackColor = Color.White;
            CheckAlignment = ContentAlignment.MiddleCenter;
            TextAlignment = ContentAlignment.MiddleCenter;
            MultiSelect = false;
        }
    }
 
    public sealed class GridViewButtonElement : RadButtonElement
    {
        public GridViewButtonElement(string name, Image image = null, string text = null)
        {
            if (image != null)
            {
                Image = ResizeImage(image, 25, 25);
                ImageAlignment = ContentAlignment.MiddleCenter;
            }
 
            DisplayStyle = image != null && string.IsNullOrWhiteSpace(text)
                ? DisplayStyle.ImageAndText
                : image != null
                    ? DisplayStyle.Image
                    : DisplayStyle.Text;
 
            Name = name;
            Text = text;
            Alignment = ContentAlignment.MiddleCenter;
            ShowBorder = false;
            BackColor = Color.White;
        }
 
        private Bitmap ResizeImage(Image image, int width, int height)
        {
            var destRect = new Rectangle(0, 0, width, height);
            var destImage = new Bitmap(width, height);
 
            destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
 
            using (var graphics = Graphics.FromImage(destImage))
            {
                graphics.CompositingMode = CompositingMode.SourceCopy;
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
 
                using (var wrapMode = new ImageAttributes())
                {
                    wrapMode.SetWrapMode(WrapMode.TileFlipXY);
                    graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
                }
            }
 
            return destImage;
        }
    }

Thanks,

Paul.

Dimitar
Telerik team
 answered on 09 May 2017
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
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?