Telerik Forums
UI for WinForms Forum
6 answers
412 views

Is possible to copy cell content from one row to onther new added row in radgridview

winform

Thanks a lot

fabrizio
Top achievements
Rank 1
Veteran
 answered on 20 Jul 2020
2 answers
114 views

I've been playing with the 2020 R1 demo and am having trouble setting and getting column widths of the VirtualGrid.

To set the column widths I've tried both TableElement, as in the documentation, and MasterViewInfo, which I found in the forums.

A little insight would be great!

 

Thanks!

using System;
using System.Collections.Generic;
using Telerik.WinControls.UI;
 
namespace TelerikWinFormsApp1
{
    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        List<Foo> data = new List<Foo>();
 
        public RadForm1()
        {
            InitializeComponent();
            this.Text = "Foo";
 
            radVirtualGrid1.AutoSize = false;
            this.radVirtualGrid1.CellValueNeeded += new Telerik.WinControls.UI.VirtualGridCellValueNeededEventHandler(this.radVirtualGrid1_CellValueNeeded);
            this.radVirtualGrid1.ColumnWidthChanged += new Telerik.WinControls.UI.VirtualGridColumnEventHandler(this.radVirtualGrid1_ColumnWidthChanged);
 
            //These methods do not set the column width
            radVirtualGrid1.MasterViewInfo.SetColumnWidth(0, 300);
            radVirtualGrid1.MasterViewInfo.SetColumnWidth(1, 150);
            radVirtualGrid1.TableElement.SetColumnWidth(0, 300);
            radVirtualGrid1.TableElement.SetColumnWidth(1, 150);
 
            LoadData();
        }
 
        private void radVirtualGrid1_ColumnWidthChanged(object sender, VirtualGridColumnEventArgs e)
        {
            //This is always 100
            int i = e.ViewInfo.ColumnWidth;
        }
 
        private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e)
        {
            if (e.ViewInfo == this.radVirtualGrid1.MasterViewInfo)
            {
                if (e.ColumnIndex < 0)
                {
                    return;
                }
 
                e.FieldName = Foo.FieldNames[e.ColumnIndex];
 
                if (e.RowIndex == RadVirtualGrid.HeaderRowIndex)
                {
                    e.Value = e.FieldName;
                }
                else if (e.RowIndex >= 0)
                {
                    e.Value = data[e.RowIndex][e.ColumnIndex];
                }
            }
        }
 
        private void LoadData()
        {
            Random random = new Random();
 
            for (int i = 0; i < 10; i++)
            {
                Foo Foo = new Foo();
                Foo.Me = i;
                Foo.Yu = i;
                data.Add(Foo);
            }
 
            this.radVirtualGrid1.RowCount = data.Count;
            this.radVirtualGrid1.ColumnCount = Foo.FieldNames.Length;
        }
    }
 
    public class Foo
    {
        public static readonly string[] FieldNames = { "Me", "Yu" };
        public int Me { get; set; }
        public int Yu { get; set; }
 
        public int this[int index]
        {
            get
            {
                switch (index)
                {
                    case 0: return Me;
                    case 1: return Yu;
                    default: return 0;
                }
            }
        }
    }
Dave
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 20 Jul 2020
5 answers
109 views
I suggest adding something to the RadTreeView that allows for getting which mouse button is being pressed on individual nodes. Maybe adding Button to the RadTreeViewEventArgs that returns a MouseButtons value.

For what I'm doing it won't make a huge difference, but it would help to know in certain circumstances.
Nadya | Tech Support Engineer
Telerik team
 answered on 20 Jul 2020
2 answers
2.0K+ views

Hi,

I have an issue where I had originally set the combobox textbox alignment to the right with:

// **** Align Drop Down Box Text to Right
revPurgeCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
addPurgeCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
scrapCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
scrapRsnDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
// ************************

And it worked correctly.  But then I decided I didn't want the user to be able to input anything, only select from drop down.  So I added raddropdownstyle.dropdownlist:

// **** not allow use to type in
scrapCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
scrapRsnDropList.DropDownStyle = RadDropDownStyle.DropDownList;
revPurgeCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
addPurgeCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
// ************************

The raddropdownstyle.dropdownlist worked, but the alignment isn't working any longer.  I tried to put this before and I tried after before it's the same. Am I doing something wrong? Here's what I have now:

// **** not allow use to type in
scrapCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
scrapRsnDropList.DropDownStyle = RadDropDownStyle.DropDownList;
revPurgeCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
addPurgeCodeDropList.DropDownStyle = RadDropDownStyle.DropDownList;
// ************************
 
// **** Align Drop Down Box Text to Right
revPurgeCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
addPurgeCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
scrapCodeDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
scrapRsnDropList.MultiColumnComboBoxElement.TextBoxElement.TextAlign = HorizontalAlignment.Right;
// ************************
Lily
Top achievements
Rank 1
Veteran
 answered on 20 Jul 2020
1 answer
83 views
A gridview (read only) has a quantity column that is normally formatted with zero decimal positions.  Now we have a situation where the values in some rows will have significant decimal values and others will not.  Can I set the decimal format of individual cells (hoping that CellFormatting event is part of that solution)?
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 17 Jul 2020
12 answers
562 views

Hi all,

I just downloaded the Telerik UI for Winforms 2018_2_621 and started "tinkering" around with the RadImageEditor control for a specific project I am currently working on for work. I was wondering, is there a way to "hide" or "disable" the buttons on the toolbar on the left hand side of the image editor? Or (perhaps the most ideal for me) is there a way to completely hide the toolbar altogether on the left hand side?

I thought this would be a simple "enable" or "disable" on a property of the control, but I can't seem to find any documentation on this matter. Thank you and I look forward to the response.

Nadya | Tech Support Engineer
Telerik team
 answered on 16 Jul 2020
8 answers
746 views
Im looking for a way to copy multiple rows from Excel and paste them in to an empty grid.  There doesnt seem to be a way to do this by default?  How would I go about implementing this.  If i add a blank row I can then paste the multiple rows but then the default values for the other columns dont get filled in.

With a normal grid I used the following code:  This would also add the "Default Values" for the other columns as well.

private void PasteClipboard()
       {
           char[] rowSplitter = { '\r', '\n' };
           char[] columnSplitter = { '\t' };
 
           // Get the text from clipboard
           IDataObject dataInClipboard = Clipboard.GetDataObject();
           string stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);
 
           // Split it into lines
           string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);
 
           // Get the row and column of selected cell in grid
           int r = ColumnsGrid.SelectedCells[0].RowIndex;
           int c = ColumnsGrid.SelectedCells[0].ColumnIndex;
 
           // Add rows into grid to fit clipboard lines
           if (ColumnsGrid.Rows.Count < (r + rowsInClipboard.Length))
           {
               ColumnsGrid.Rows.Add(r + rowsInClipboard.Length - ColumnsGrid.Rows.Count);
           }
 
           // Loop through the lines, split them into cells and place the values in the corresponding cell.
           for (int iRow = 0; iRow < rowsInClipboard.Length; iRow++)
           {
               // Split row into cell values
               string[] valuesInRow = rowsInClipboard[iRow].Split(columnSplitter);
 
               // Cycle through cell values
               for (int iCol = 0; iCol < valuesInRow.Length; iCol++)
               {
                   // Assign cell value, only if it within columns of the grid
                   if (ColumnsGrid.ColumnCount - 1 >= c + iCol)
                   {
                       DataGridViewCell cell = ColumnsGrid.Rows[r + iRow].Cells[c + iCol];
 
                       if (!cell.ReadOnly)
                       {
                           cell.Value = valuesInRow[iCol];
                       }
                   }
               }
           }
       }
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 15 Jul 2020
3 answers
234 views

Quote from https://docs.telerik.com/devtools/winforms/controls/gridview/rows/formatting-rows:

"To customize the non-data rows (header row, new row, filtering row, etc) of RadGridView, you need to handle the ViewRowFormatting event."

 

In that regard, how can I detect newly added row/s from ViewRowFormatting event?

Please know that I couldn't use the CreateRow event since it uses UI virtualization and it doesn't trigger for newly added rows that are not "visible" on the screen.

Nadya | Tech Support Engineer
Telerik team
 answered on 14 Jul 2020
5 answers
932 views

Hi, 

I am just trying to drag&drop a file from the desktop to a simple radForm but DragDrop event do not fired, others events as DragEnter/DragOver/DragLeave works without problems but I can not detect when the user perform drag&Drop with the file into the form.

any idea why I can not catch this event?

namespace Drag
{
    partial class RadForm1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <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);
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.visualStudio2012LightTheme1 = new Telerik.WinControls.Themes.VisualStudio2012LightTheme();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // RadForm1
            //
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(643, 488);
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "RadForm1";
            //
            //
            //
            this.RootElement.ApplyShapeToControl = true;
            this.Text = "RadForm1";
            this.ThemeName = "VisualStudio2012Light";
            this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragDrop);
            this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragEnter);
            this.DragOver += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragOver);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private Telerik.WinControls.Themes.VisualStudio2012LightTheme visualStudio2012LightTheme1;
    }
}
 
namespace Drag
{
    partial class RadForm1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <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);
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.visualStudio2012LightTheme1 = new Telerik.WinControls.Themes.VisualStudio2012LightTheme();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // RadForm1
            //
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(643, 488);
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "RadForm1";
            //
            //
            //
            this.RootElement.ApplyShapeToControl = true;
            this.Text = "RadForm1";
            this.ThemeName = "VisualStudio2012Light";
            this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragDrop);
            this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragEnter);
            this.DragOver += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragOver);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private Telerik.WinControls.Themes.VisualStudio2012LightTheme visualStudio2012LightTheme1;
    }
}

 

Thanks a lot.

Francisco

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 14 Jul 2020
1 answer
2.2K+ views

I'd like to change progressbar color depending on value, for example:

>50 - red

<=50 - green

 

How to do it in app? 

 

 

Nadya | Tech Support Engineer
Telerik team
 answered on 13 Jul 2020
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?