Telerik Forums
UI for WinForms Forum
3 answers
301 views
Greetings,

I have a custom object that I am using for databinding. I tried to post the sample as a zip file to repeat the problem I am seeing. Maybe I did my custom objects wrong, I really dont know. However, my problem is this, when binding to Hierarchy data if you select a row and expand the child data is shown, however if you select the next row and expand it, then the first child result loses its binding, and you have no data. I am considering purchasing your product for a project, and need your advice...is this a bug? or is my code incorrect? I have custom objects, and I am not using DataSets or DataTables...nor do I want to use those, so those examples really dont help.



Sample Code:

Form1.cs
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;

namespace TelerikWindowsTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private BusinessTestList _testItemList;

        private void Form1_Load(object sender, EventArgs e)
        {
            _testItemList = new BusinessTestList();

            BusinessTestItem item = new BusinessTestItem();
            item.Name = "Joe";
            item.SubItems.Add(new SubItem() { Count = 22, Date = DateTime.Now });
            item.SubItems.Add(new SubItem() { Count = 1, Date = DateTime.Now });
            item.SubItems.Add(new SubItem() { Count = 56, Date = DateTime.Now });
            item.SubItems.Add(new SubItem() { Count = 75, Date = DateTime.Now });
            item.SubItems.Add(new SubItem() { Count = 84, Date = DateTime.Now });
            _testItemList.Add(item);

            BusinessTestItem secondItem = new BusinessTestItem();
            secondItem.Name = "Jack";
            secondItem.SubItems.Add(new SubItem() { Count = 1, Date = DateTime.Now });
            secondItem.SubItems.Add(new SubItem() { Count = 2, Date = DateTime.Now });
            secondItem.SubItems.Add(new SubItem() { Count = 45, Date = DateTime.Now });
            secondItem.SubItems.Add(new SubItem() { Count = 67, Date = DateTime.Now });
            secondItem.SubItems.Add(new SubItem() { Count = 89, Date = DateTime.Now });
            _testItemList.Add(secondItem);

            radGridView1.DataSource = _testItemList;
            radGridView1.MasterGridViewTemplate.ChildGridViewTemplates[0].DataMember = "SubItems";
            radGridView1.MasterGridViewTemplate.ChildGridViewTemplates[0].DataSource = _testItemList;
        }

    }

    public class BusinessTestList : BindingList<BusinessTestItem>
    {

    }

    public class BusinessTestItem : INotifyPropertyChanged
    {
        public BusinessTestItem()
        {
            subItems = new SubItemList();

            subItems.ListChanged += new ListChangedEventHandler(subItems_ListChanged);
        }

        private string name = string.Empty;
        private SubItemList subItems;

        public SubItemList SubItems
        {
            get
            {
                return subItems;
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value != this.name)
                {
                    this.name = value;
                    OnPropertyChanged("Name");
                }
            }
        }

        public double Total
        {
            get
            {
                var value = this.SubItems.Sum(x => x.Count);
                return value;
            }
        }

        #region INotifyPropertyChanged Members

        public void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        public void subItems_ListChanged(object sender, ListChangedEventArgs e)
        {
            OnPropertyChanged("Total");
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

    public class SubItemList : BindingList<SubItem>
    {

    }

    public class SubItem : INotifyPropertyChanged
    {
        private double count = 0;
        private DateTime date = DateTime.Now;

        public double Count
        {
            get
            {
                return count;
            }
            set
            {
                if (value != this.count)
                {
                    this.count = value;
                    OnPropertyChanged("Count");
                }
            }
        }

        public DateTime Date
        {
            get
            {
                return this.date;
            }
            set
            {
                if (value != this.date)
                {
                    this.date = value;
                    OnPropertyChanged("Date");
                }
            }
        }

        #region INotifyPropertyChanged Members

        public void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

}

Form1.Designer.cs:

namespace TelerikWindowsTest
{
    partial class Form1
    {
        /// <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.components = new System.ComponentModel.Container();
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn3 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn4 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn4 = new Telerik.WinControls.UI.GridViewDecimalColumn();
            Telerik.WinControls.UI.GridViewRelation gridViewRelation2 = new Telerik.WinControls.UI.GridViewRelation();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn3 = new Telerik.WinControls.UI.GridViewDecimalColumn();
            Telerik.WinControls.UI.GridViewDateTimeColumn gridViewDateTimeColumn2 = new Telerik.WinControls.UI.GridViewDateTimeColumn();
            this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
            this.miscellaneousTheme1 = new Telerik.WinControls.Themes.MiscellaneousTheme();
            this.buisnessTestListBindingSource = new System.Windows.Forms.BindingSource(this.components);
            this.gridViewTemplate1 = new Telerik.WinControls.UI.GridViewTemplate();
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.buisnessTestListBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridViewTemplate1)).BeginInit();
            this.SuspendLayout();
            //
            // radGridView1
            //
            this.radGridView1.BackColor = System.Drawing.SystemColors.Control;
            this.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
            this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.radGridView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText;
            this.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
            this.radGridView1.Location = new System.Drawing.Point(0, 0);
            //
            //
            //
            this.radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.AddRange(new Telerik.WinControls.UI.GridViewTemplate[] {
            this.gridViewTemplate1});
            gridViewTextBoxColumn3.DataType = typeof(TelerikWindowsTest.SubItemList);
            gridViewTextBoxColumn3.FieldAlias = "SubItems";
            gridViewTextBoxColumn3.FieldName = "SubItems";
            gridViewTextBoxColumn3.HeaderText = "SubItems";
            gridViewTextBoxColumn3.IsAutoGenerated = true;
            gridViewTextBoxColumn3.IsVisible = false;
            gridViewTextBoxColumn3.ReadOnly = true;
            gridViewTextBoxColumn3.UniqueName = "SubItems";
            gridViewTextBoxColumn3.Width = 88;
            gridViewTextBoxColumn4.FieldAlias = "Name";
            gridViewTextBoxColumn4.FieldName = "Name";
            gridViewTextBoxColumn4.HeaderText = "Name";
            gridViewTextBoxColumn4.IsAutoGenerated = true;
            gridViewTextBoxColumn4.UniqueName = "Name";
            gridViewTextBoxColumn4.Width = 96;
            gridViewDecimalColumn4.DataType = typeof(double);
            gridViewDecimalColumn4.FieldAlias = "Total";
            gridViewDecimalColumn4.FieldName = "Total";
            gridViewDecimalColumn4.HeaderText = "Total";
            gridViewDecimalColumn4.IsAutoGenerated = true;
            gridViewDecimalColumn4.ReadOnly = true;
            gridViewDecimalColumn4.UniqueName = "Total";
            gridViewDecimalColumn4.Width = 115;
            this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn3);
            this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn4);
            this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewDecimalColumn4);
            this.radGridView1.MasterGridViewTemplate.DataSource = this.buisnessTestListBindingSource;
            this.radGridView1.Name = "radGridView1";
            gridViewRelation2.ChildColumnNames = ((System.Collections.Specialized.StringCollection)(resources.GetObject("gridViewRelation2.ChildColumnNames")));
            gridViewRelation2.ChildTemplate = this.gridViewTemplate1;
            gridViewRelation2.ParentColumnNames = ((System.Collections.Specialized.StringCollection)(resources.GetObject("gridViewRelation2.ParentColumnNames")));
            gridViewRelation2.ParentTemplate = this.radGridView1.MasterGridViewTemplate;
            gridViewRelation2.RelationName = "RelationShip";
            this.radGridView1.Relations.Add(gridViewRelation2);
            this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.radGridView1.Size = new System.Drawing.Size(442, 273);
            this.radGridView1.TabIndex = 0;
            this.radGridView1.Text = "radGridViewPreview";
            this.radGridView1.ThemeName = "Office2007Blue";
            //
            // buisnessTestListBindingSource
            //
            this.buisnessTestListBindingSource.DataSource = typeof(TelerikWindowsTest.BusinessTestList);
            this.buisnessTestListBindingSource.Position = 2;
            //
            // gridViewTemplate1
            //
            gridViewDecimalColumn3.DataType = typeof(double);
            gridViewDecimalColumn3.FieldAlias = "Count";
            gridViewDecimalColumn3.FieldName = "Count";
            gridViewDecimalColumn3.HeaderText = "Count";
            gridViewDecimalColumn3.IsAutoGenerated = true;
            gridViewDecimalColumn3.UniqueName = "Count";
            gridViewDateTimeColumn2.DataType = typeof(System.DateTime);
            gridViewDateTimeColumn2.FieldAlias = "Date";
            gridViewDateTimeColumn2.FieldName = "Date";
            gridViewDateTimeColumn2.HeaderText = "Date";
            gridViewDateTimeColumn2.IsAutoGenerated = true;
            gridViewDateTimeColumn2.UniqueName = "Date";
            this.gridViewTemplate1.Columns.Add(gridViewDecimalColumn3);
            this.gridViewTemplate1.Columns.Add(gridViewDateTimeColumn2);
            this.gridViewTemplate1.DataMember = "SubItems";
            this.gridViewTemplate1.DataSource = this.buisnessTestListBindingSource;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(442, 273);
            this.Controls.Add(this.radGridView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.buisnessTestListBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridViewTemplate1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private Telerik.WinControls.UI.RadGridView radGridView1;
        private Telerik.WinControls.Themes.MiscellaneousTheme miscellaneousTheme1;
        private System.Windows.Forms.BindingSource buisnessTestListBindingSource;
        private Telerik.WinControls.UI.GridViewTemplate gridViewTemplate1;
    }
}

 






Thank you,
Jeff
Julian Benkov
Telerik team
 answered on 04 Jun 2010
1 answer
131 views
I have run into an interesting issue.

I have a datagrid that I have linked to an OrganizationName data source. Inside the OrganizationName object, we have setup a link to another object called OrgnanizationNameType.

On the datagrid, I want to have two columns. The first column is linked to the OrganizationName data source and the second column is linked to the OrganizationNameType data source.

When the datagrid loads, I need to to have the value of the OrganizationNameType to be linked to the value inside the OrganizationName object. I need this done in a drop down for easy editing.

Is this possible?
Jack
Telerik team
 answered on 04 Jun 2010
3 answers
184 views
Hi!

I've reinstalled my computer, and now my project won't build.
"The type or namespace name 'RadPopupForm' could not be found (are you missing a using directive or an assembly reference?)"  

I'm using VS 2005 and WinForms 2010.1.10.308_dev

If I comment out this section, everything else is ok. And it was ok before reinstalling windows7.

        private void radComboBoxAgreement_DropDownOpened(object sender, EventArgs e) 
        { 
            //getting the popup form which size should be set   
            RadPopupForm popup = (RadPopupForm)radComboBoxAgreement.Items[0].ElementTree.Control; 
 
            int desiredWidth = (int)radComboBoxAgreement.ComboBoxElement.ListBoxElement.Viewport.DesiredSize.Width; 
            RadScrollLayoutPanel scrollPanel = (RadScrollLayoutPanel)radComboBoxAgreement.ComboBoxElement.ListBoxElement.Children[2]; 
 
            if (desiredWidth > radComboBoxAgreement.Width) 
            { 
                if (scrollPanel.CanVerticalScroll) 
                { 
                    desiredWidth += radComboBoxAgreement.ComboBoxElement.ListBoxElement.ScrollThickness; 
                } 
 
                //adding border width (both left and right) of the inner listbox element.    
                desiredWidth += radComboBoxAgreement.ComboBoxElement.ListBoxElement.BorderThickness.Horizontal; 
 
                popup.Size = new Size(desiredWidth, popup.Height); 
            } 
        } 

Deyan
Telerik team
 answered on 04 Jun 2010
1 answer
119 views
I am using a custom theme built in VSB for an application. However, the RadListBox does not get any theming. The XML is present and the ThemeManager has it loaded. What is the deal with these controls?
Victor
Telerik team
 answered on 04 Jun 2010
1 answer
131 views

I write the program in VB.
I have a RadGrid with some GridViewMaskBoxColumns with Mask="n3" and MaskType=Numeric.
When i put negative values in that cell afer i finish the edit the minus symbol disappears.
How can i put negative values in those cells?
Alexander
Telerik team
 answered on 04 Jun 2010
1 answer
118 views
What is the best way to plot dates on a linear time-line? -e.g. Say I have 2 data points on Monday, none on Tues/Wed, and 3 on Thurs; I want the chart to group these in a way that's easy to see the dispersion of data over the week - now it just shows 5 evenly spaced points.
I could just add data; except my resolution is 1 second and the timescale could be months...
Dwight
Telerik team
 answered on 04 Jun 2010
1 answer
119 views

Hallo.

Please, could you give me an adwace how to use RadWaitingBarElement in RadGridView and run this element. I have try used it in cell_formating, but element do not run.

(it is trial Version: 2010.1 504 , C#, vs 2008 )

Thank you for advice or source code.

Tomas

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)      
{      
if (e.CellElement.RowIndex < 0) return;      
if (((GridViewDataColumn)e.CellElement.ColumnInfo).FieldName == "test")      
{      
RadWaitingBarElement element = new RadWaitingBarElement();      
element.StretchHorizontally = true;      
element.StretchVertically = true;      
element.waitingTimer = this.timer1;//timer is running      
e.CellElement.Children.Add(element);      
}     
   
 

 

Nikolay
Telerik team
 answered on 04 Jun 2010
1 answer
355 views
I'm sure this must be simple, but I can't figure out how to do it.

When I resize a raddock with a toolwindow on the side, the toolwindow resizes proportionately along with the whole dock. I want to keep the toolwindow on the side the same size always, and allow the "slack" to be taken up by the other toolwindows.

I can't seem to find a MaximumSize property for the Toolwindow.

How do I do this?
Nikolay
Telerik team
 answered on 03 Jun 2010
2 answers
203 views

I am experiencing some issues with allowing the user to filter data in the grid. We are using Telerik.WinControls.GridView, v8.2.0.0. In the designer, i have the following code:

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn1);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn2);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn3);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn4);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn5);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn6);

 

 

this.grdAuditDetails.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn7);

 

 

this.grdAuditDetails.EnableFiltering = true;

 

 

this.grdAuditDetails.MasterGridViewTemplate.EnableFiltering = true;

 

 

this.grdAuditDetails.MasterGridViewTemplate.EnableGrouping = false;

 

 

this.grdAuditDetails.MultiSelect = false;

 

 

this.grdAuditDetails.Name = "grdAuditDetails";

 

 

this.grdAuditDetails.ReadOnly = true;

 

 

this.grdAuditDetails.RightToLeft = System.Windows.Forms.RightToLeft.No;

 

 

//

 

 

//

 

 

//

 

 

this.grdAuditDetails.RootElement.ForeColor = System.Drawing.SystemColors.GradientActiveCaption;

 

 

this.grdAuditDetails.ShowGroupPanel = false;

 

 

this.grdAuditDetails.Size = new System.Drawing.Size(791, 590);

 

 

this.grdAuditDetails.TabIndex = 94;

 

 

this.grdAuditDetails.TabStop = false;

 

 

this.grdAuditDetails.Text = "radGridViewPreview";

 

 

this.grdAuditDetails.ThemeName = "Breeze";

 

((Telerik.WinControls.UI.

GridTableElement)(this.grdAuditDetails.GetChildAt(0))).CellSpacing = -1;

 

((Telerik.WinControls.UI.

GridTableElement)(this.grdAuditDetails.GetChildAt(0))).TableHeaderHeight = 26;

 

((Telerik.WinControls.UI.

GridTableElement)(this.grdAuditDetails.GetChildAt(0))).BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(246)))));

 

((Telerik.WinControls.UI.

GridTableElement)(this.grdAuditDetails.GetChildAt(0))).Padding = new System.Windows.Forms.Padding(3);

 

 

On the form, i can see the filter icons for the fields, but when the user speicifies how they want to filter and add their criteria, nothing happens. Can anyone please help me out with this issue?

Thanks!

Craig

Craig
Top achievements
Rank 1
 answered on 03 Jun 2010
1 answer
117 views

Hi,

        How to do i customize the back color of a particular Date in Day View or Weekly View by code.

Regards

Nitin

Dobry Zranchev
Telerik team
 answered on 03 Jun 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)
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
PdfViewer and PdfViewerNavigator
CommandBar
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
Label
AutoCompleteBox
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
SyntaxEditor
Wizard
CollapsiblePanel
LayoutControl
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
SmartPasteButton
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?