Telerik Forums
UI for WinForms Forum
1 answer
188 views
Hi Experts,
I want a solution regarding telerik gridview.

I have one Master Grid and one Child Grid view. And i Want a Conditional Column Merging in Child Grid View Template according to the value in one cell.

I have Attached two screen shots for it. 1 Named "Current - Output" is Current Output and 2nd one named "Expected - Output" is Expected  Output.
Waiting for the Positive Response.

Thank You,
Jignesh Patel.
Jack
Telerik team
 answered on 15 Feb 2010
2 answers
254 views

I have control inherited from RadTreeView.

In my constructor i have set

 

AllowDragDrop =

true;

 

void

 

TreeView_ItemDrag(object sender, RadTreeViewEventArgs e)

 

{

 

   //Does nothing

 

}

 

void

 

TreeView_DragEnter(object sender, DragEventArgs e)

 

{

e.Effect =

DragDropEffects.Move;

 

}

 

void

 

TreeView_DragDrop(object sender, DragEventArgs e)
{
  //My business logic....
}

TreeView_DragDrop even is never get executed when i drop a RadTreeNode before/after another RadTreeNode in the view.

Please help...

 

Victor
Telerik team
 answered on 15 Feb 2010
1 answer
122 views
Hi..
     I have RadGridView that takes input from user on runtime. when user clicks new row, instead of completing the first, he must be restrained to enter in new row, I am able to prompt the user to complete the input in first row, but second row is created on clicking on it. I have used Janus Grid before, it has event 'e.cancel = true' option in RowsAdded event. but no such thing in RadGridView. Any solution to restrain empty rows being entered by user..Please Help...?????
Nick
Telerik team
 answered on 15 Feb 2010
3 answers
103 views
What is the control used for the left hand menu in the Run Demo main application?
Nick
Telerik team
 answered on 15 Feb 2010
2 answers
161 views

I have created a control derived from Telerik.WinControls.UI.RadTreeView (Latest trial version)

I am also creating the RadTreeNode on fly..

I am setting below properties at runtime.

groupTreeView.AllowArbitaryItemHeight =

true;

 

 

 groupTreeView.AllowPlusMinusAnimation = 

true;

 

 

 groupTreeView.DropFeedbackColor = 

Color.Black;

 

 

 groupTreeView.Enabled = 

true;

 

 

 groupTreeView.ExpandAnimation =

ExpandAnimation.Opacity;

 

 

 groupTreeView.Focusable =

true;

 

 

 

groupTreeView.PlusMinusAnimationStep = 10;

 

groupTreeView.ShowExpandCollapse =

true;

 

 

 groupTreeView.ToggleMode =

ToggleMode.SingleClick;

 

 

 groupTreeView.UseNewLayoutSystem =

true;

but this does not show me the Expand(+) and collapse(-) sign.


Note my TreeViewXML..
<?xml version="1.0" encoding="utf-16"?>
<TreeView xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" UseDefaultSelection="true" AllowDragDrop="true" AllowPlusMinusAnimation="true" ThemeName="Office2007Black" AllowDrop="true" BackColor="Window" DropFeedbackColor="Red" LineColor="ActiveCaption">
</TreeView>
Please help..

 

 

 

 

Raj Sharma
Top achievements
Rank 1
 answered on 12 Feb 2010
1 answer
117 views
Hi

I use RadControls for WinForms Q3 2009 SP1.

In order to add a node to an existing node I need to know what the last selected node was, and SelectedNodeChanged works perfectly for this.

The problem is when I want to add a node to the root of the TreeView, I click on the TreeView itself (not on a node) and SelectedNodeChanged is *not* fired with RadTreeViewEventArgs.Node = null.  Any idea how I can get around this?

Thanks
Ralph
Victor
Telerik team
 answered on 12 Feb 2010
1 answer
124 views
If you compile and run the following snippet, and then follow the steps below;
1. Click add new row (row is defaulted with values);
2. Change the value in the Status column to 4, then hit enter;
The display value for row 5 has been updated with the same values for status and review date.  However the underlying datasource is correctly updated.  The display is different to the underlying object.
This took a while to fathom out (Ive been working with legacy code implementing new features using the Telerik controls).  The problem occurs with the fact that in our ancestor class Equals has been overriden.  In the concrete classes a field called SqlKeyString is overriden and this provides a "key" for the objects to do an equality test.
It therefore looks like the RadGridView is using "Equals" rather than "==", my question is therefore should the RadGridView really be using "==" rather than "Equals"?
My 2nd issue with the gridview, is when adding a new row the CellFormatting doesnt apply to the new row.  When you click a new row in this example a date with value DateTime.MinValue should be displayed as an string.Empty, however the actual value is displayed.
Thanks for your attention,
Dave
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using Telerik.WinControls.UI; 
 
namespace TelerikDataGridView 
    #region Form 
    public class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
        /// <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.radGridView1 = new Telerik.WinControls.UI.RadGridView(); 
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit(); 
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).BeginInit(); 
            this.SuspendLayout(); 
            //  
            // radGridView1 
            //  
            this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill; 
            this.radGridView1.Location = new System.Drawing.Point(0, 0); 
            this.radGridView1.Name = "radGridView1"
            this.radGridView1.Size = new System.Drawing.Size(905, 285); 
            this.radGridView1.TabIndex = 0; 
            //  
            // Form3 
            //  
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
            this.ClientSize = new System.Drawing.Size(905, 285); 
            this.Controls.Add(this.radGridView1); 
            this.Name = "Form3"
            this.Text = "Form3"
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).EndInit(); 
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit(); 
            this.ResumeLayout(false); 
 
        } 
        #endregion 
 
        private Telerik.WinControls.UI.RadGridView radGridView1; 
        protected override void OnLoad(EventArgs e) 
        { 
            base.OnLoad(e); 
            CreateGrid(); 
        } 
        private void CreateGrid() 
        { 
            BindingSource source = new BindingSource(); 
            source.AllowNew = true
            source.AddingNew += new AddingNewEventHandler(source_AddingNew); 
 
            source.DataSource = new MyCollection(); 
            this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false
            this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); 
            radGridView1.DataSource = source; 
 
            AddTextColumn("FundManagerId""Fund Manager"); 
            AddTextColumn("AssetClassId""Asset Class"); 
            AddTextColumn("ClientOrgId""Client"); 
            AddTextColumn("Status""Status"); 
            AddDateColumn("ReviewDate""Review Date"true); 
 
            radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;             
        } 
 
        void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
        { 
            if (e.CellElement is GridDateTimeCellElement) 
            { 
                GridDateTimeCellElement cell = e.CellElement as GridDateTimeCellElement; 
                if (cell.IsEditMode) 
                    return
 
                if (((DateTime)cell.Value).Equals(DateTime.MinValue)) 
                    cell.Text = string.Empty; 
                else 
                    cell.Text = string.Format("{0:dd/MM/yyyy}", (DateTime)cell.Value); 
            }  
        } 
        int assetClass = 5; 
        void source_AddingNew(object sender, AddingNewEventArgs e) 
        { 
            e.NewObject = new MyClass(12, 5, assetClass++, 2, DateTime.MinValue); 
        } 
 
        private void AddTextColumn(string field, string header) 
        { 
            AddTextColumn(field, header, false); 
        } 
        private void AddTextColumn(string field, string header, bool readOnly) 
        { 
            GridViewTextBoxColumn column = new GridViewTextBoxColumn(field); 
            column.HeaderText = header; 
            column.ReadOnly = readOnly; 
            radGridView1.MasterGridViewTemplate.Columns.Add(column); 
        } 
        private void AddDateColumn(string field, string header) 
        { 
            AddDateColumn(field, header, false); 
        } 
        private void AddDateColumn(string field, string header, bool readOnly) 
        { 
            GridViewDateTimeColumn dateColumn = new GridViewDateTimeColumn(); 
            dateColumn.BestFit(); 
            dateColumn.FieldName = field; 
            dateColumn.FormatString = "{0:dd/MM/yyyy}"
            dateColumn.HeaderText = header; 
            dateColumn.ReadOnly = readOnly; 
            dateColumn.TextAlignment = ContentAlignment.MiddleCenter; 
            radGridView1.MasterGridViewTemplate.Columns.Add(dateColumn); 
        } 
    } 
    #endregion 
    #region DataSources 
    public class MyClass : InvestmentObject 
    { 
        public MyClass(int client, int fundManager, int assetClass, int status, DateTime statusDate) 
        { 
            FundManagerId = fundManager; 
            AssetClassId = assetClass; 
            ClientOrgId = client; 
            ReviewDate = statusDate; 
            Status = status; 
        } 
        public MyClass(int client, int fundManager, int assetClass) 
            : this(client, fundManager, assetClass, 1, DateTime.Now) 
        { 
 
        } 
        private int _fundManagerId; 
        public int FundManagerId 
        { 
            get { return _fundManagerId; } 
            set 
            { 
                _fundManagerId = value; 
                OnPropertyChanged("FundManagerId"); 
            } 
        } 
 
        private int _assetClassId; 
        public int AssetClassId 
        { 
            get { return _assetClassId; } 
            set 
            { 
                _assetClassId = value; 
                OnPropertyChanged("AssetClassId"); 
            } 
        } 
 
        private int _clientOrgId; 
        public int ClientOrgId 
        { 
            get { return _clientOrgId; } 
            set 
            { 
                _clientOrgId = value; 
                OnPropertyChanged("ClientOrgId"); 
            } 
        } 
 
        private int _status; 
        public int Status 
        { 
            get { return _status; } 
            set 
            { 
                _status = value; 
                OnPropertyChanged("Status"); 
            } 
        } 
 
        private DateTime _reviewDate; 
        public DateTime ReviewDate 
        { 
            get { return _reviewDate; } 
            set 
            { 
                _reviewDate = value; 
                OnPropertyChanged("ReviewDate"); 
            } 
        } 
 
        public override string SqlKeyString 
        { 
            get 
            { 
                return string.Format("FundManagerId={0} and AssetClassId={1} and ClientOrgId={2}" 
                  , FundManagerId, AssetClassId, ClientOrgId); 
            } 
        } 
    } 
 
    public class MyCollection : DataList<MyClass> 
    { 
        public MyCollection() 
        { 
            Add(new MyClass(12, 5, 1)); 
            Add(new MyClass(12, 5, 2)); 
            Add(new MyClass(12, 5, 3)); 
            Add(new MyClass(12, 5, 4)); 
            Add(new MyClass(12, 5, 5)); 
        } 
    } 
    #endregion 
    #region Supporting Data Objects 
    public abstract class DataList<T> : BindingList<T> 
    { 
        public void Sort(Comparison<T> comparer) 
        { 
            ((List<T>)this.Items).Sort(comparer); 
        } 
        public void Sort(IComparer<T> comparer) 
        { 
            ((List<T>)this.Items).Sort(comparer); 
        } 
    } 
    public abstract class InvestmentObject : INotifyPropertyChanged 
    { 
        #region Private Fields 
 
        private DateTime lastModified; 
        private Guid guid; 
        #endregion 
        #region Constructors 
 
        protected InvestmentObject() 
            : base() 
        { 
            lastModified = DateTime.Now; 
            guid = Guid.NewGuid(); 
        } 
        #endregion 
        #region Data Properties 
 
        public DateTime LastModified 
        { 
            get { return lastModified; } 
            protected set { lastModified = value; } 
        } 
 
        public Guid CurrentGUID 
        { 
            get { return guid; } 
            protected set { guid = value; } 
        } 
        #endregion 
 
        public override bool Equals(object obj) 
        { 
            if ((obj != null) && (obj.GetType() == this.GetType())) 
            { 
                InvestmentObject dataAccessObject = obj as InvestmentObject; 
 
                return (dataAccessObject.SqlKeyString == this.SqlKeyString); 
            } 
            else return false
        } 
        public override int GetHashCode() 
        { 
            return (this.GetType().ToString() + SqlKeyString).GetHashCode(); 
        } 
        #region Abstract 
        public abstract string SqlKeyString { get; } 
        #endregion 
        #region INotifyPropertyChanged Members 
 
        public event PropertyChangedEventHandler PropertyChanged; 
 
        protected virtual void OnPropertyChanged(string field) 
        { 
            if (PropertyChanged != null
                PropertyChanged(thisnew PropertyChangedEventArgs(field)); 
        } 
        #endregion 
    } 
    #endregion 
 
Martin Vasilev
Telerik team
 answered on 12 Feb 2010
2 answers
109 views
 Hello,
I have hooked an event handler to the DockStateChanged event in order to intercept the tool windows that were being detached from the dock. Once I find a tool window whose DockState has turned to Floating I adjust its size and change the border style so that the user cannot resize it anymore while it is floating. However I encountered a small problem with this approach: if I detach the tool window by clicking its tab and dragging it out of the tab strip the FloatingParent field of the DockWindow provided in the event arguments is properly set and I can alter it. However if I double-click on the tab or use the context menu to make the window floating the FloatingParent field is set to null. Curiously this only happens the first time I undock the window this way, if I dock the window again and then undock it FloatingPanel is not null anymore (the same is true if I undock the window by dragging it out of the tab strip). Is this an intended behavior or a bug? Here's my event handler code (which throws a NullReferenceException when FloatingParent is null):

void event_DockStateChanged(object sender, DockWindowEventArgs e) 
    if (e.DockWindow.DockState == DockState.Floating) 
    { 
        // Resize a tool window to fit its contents and make it fixed-size. 
        e.DockWindow.FloatingParent.ClientSize = e.DockWindow.GetPreferredSize(Size.Empty); 
        e.DockWindow.FloatingParent.FormBorderStyle = FormBorderStyle.FixedToolWindow; 
    } 

Gabriele Svelto
Top achievements
Rank 1
 answered on 12 Feb 2010
1 answer
142 views
I have two DateTimePicker controls on a form that represent Start and End dates. I want the initially to be empty which I figured out how to do by assigning the value a database null value of 1/1/0001. The problem is that when I go to use the drop down the start date is 1/1/1900. Navigating all the way to current day is painful to the user.

Is there a way to assign the MinDate to a value like DateTime.Now but leave the value property empty? That would be the ideal scenario as my application does allow these fields to be unspecified.
Boyko Markov
Telerik team
 answered on 12 Feb 2010
6 answers
224 views
For more clear I recorded short video how it work www.8080.pl/download/dgv.wmv
I have radgridview with a datasource that is linking to a linq2sql:

TestowaBazaDataContext db = new TestowaBazaDataContext();  
 
      radGridView1.DataSource = db.tabelaZlecenias; 

When I insert a new record I want refresh the grid again:

private void radGridView1_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)  
    {  
      TestowaBazaDataContext db = new TestowaBazaDataContext();  
 
      if ((e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged) &&  
          ((int) radGridView1.Rows[e.NewStartingIndex].Cells["idZlecenia"].Value == 0))  
      {  
        //new record  
        if (radGridView1.Rows[e.NewStartingIndex].Cells["Zlecenie"].Value != null)  
        {  
          var nowa = new tabelaZlecenia()  
                       {  
                         Zlecenie = (int) radGridView1.Rows[e.NewStartingIndex].Cells["Zlecenie"].Value  
                       };  
          db.tabelaZlecenias.InsertOnSubmit(nowa);  
          db.SubmitChanges();         
 
      TestowaBazaDataContext dbZ = new TestowaBazaDataContext();  
      radGridView1.DataSource = dbZ.tabelaZlecenias;
 
        }  
      }  
    } 
 
But I see only error.
If I call if from button's event and it work correctly:

    private void button1_Click(object sender, EventArgs e)  
    {  
      //I need refresh data by Linq in radGridView1  
      TestowaBazaDataContext dbZ = new TestowaBazaDataContext();  
      radGridView1.DataSource = dbZ.tabelaZlecenias;  
    } 

But I need automatic refresh after I added records. How and where I can do it?
Robert Stuczynski
Top achievements
Rank 1
 answered on 12 Feb 2010
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
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
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
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
Styling
Barcode
BindingNavigator
PopupEditor
RibbonForm
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
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
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?