Telerik Forums
UI for WinForms Forum
1 answer
140 views

I am creating a hierarchy grid using object relational data.  I am adding a GridViewRelation manually to link the two classes together.  The data loads correctly at first, but then selecting a child row will cause all child rows in that position to be duplicated and selected.

After initial data load, everything looks great.

(See dataload.png)


Select Child 2_1 and all first position children are selected.

(see select1.png)


Select Child 3_2 and now all second position children are selected, and the first position children are now duplicates of each other and read Child 4_1.

(see select2.png)


Here is the code:

namespace TestGrid
{
    public partial class Form1 : Form
    {
        private BindingList<MasterObject> data;
 
        public Form1()
        {
            InitializeComponent();
            SetupGrid();
        }
 
        private void SetupGrid()
        {
            LoadMasterTemplate(grid.MasterTemplate);
            GridViewTemplate childTemplate = new GridViewTemplate();
            LoadChildTemplate(childTemplate);
            grid.MasterTemplate.Templates.Add(childTemplate);
 
            GridViewRelation relation = new GridViewRelation(grid.MasterTemplate, childTemplate);
            relation.RelationName = "Children";
            relation.ChildColumnNames.Add("Children");
            grid.Relations.Add(relation);
        }
 
        private void LoadMasterTemplate(GridViewTemplate template)
        {
            template.Columns.Clear();
            template.EnableFiltering = false;
            template.AllowAddNewRow = false;
            template.ShowChildViewCaptions = false;
            template.AutoGenerateColumns = false;
            template.EnableGrouping = false;
 
            GridViewTextBoxColumn colNode = new GridViewTextBoxColumn("NodeDesc");
            colNode.HeaderText = "Node";
            colNode.Name = "Node";
            colNode.ReadOnly = true;
            template.Columns.Add(colNode);
 
            GridViewTextBoxColumn colName = new GridViewTextBoxColumn("Name");
            colName.HeaderText = "Name";
            colName.Name = "Name";
            template.Columns.Add(colName);
 
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        }
 
        private void LoadChildTemplate(GridViewTemplate template)
        {
            template.Columns.Clear();
            template.EnableFiltering = false;
            template.EnableGrouping = false;
            template.AllowAddNewRow = false;
            template.AutoGenerateColumns = false;
 
            GridViewTextBoxColumn colNode = new GridViewTextBoxColumn("NodeDesc");
            colNode.HeaderText = "Node";
            colNode.Name = "Node";
            colNode.ReadOnly = true;
            template.Columns.Add(colNode);
 
            GridViewTextBoxColumn colIP = new GridViewTextBoxColumn("Name");
            colIP.Name = "Name";
            colIP.HeaderText = "Name";
            template.Columns.Add(colIP);
 
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        }
 
        private void LoadData()
        {
            data = new BindingList<MasterObject>();
 
            for (int i = 1; i < 5; i++)
            {
                MasterObject m = new MasterObject();
                m.Name = "Master " + i;
                for (int x = 1; x < i; x++)
                {
                    ChildObject c = new ChildObject();
                    c.Name = "Child " + i + "_" + x;
                    m.Children.Add(c);
                }
                data.Add(m);
            }
 
            grid.DataSource = data;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            // Load Data In Grid
            LoadData();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            // Add Child to 1
            MasterObject m = data[0];
            ChildObject c = new ChildObject();
            c.Name = "Child " + "1_" + (m.Children.Count + 1);
            m.Children.Add(c);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            // Add Child to 2
            MasterObject m = data[1];
            ChildObject c = new ChildObject();
            c.Name = "Child " + "2_" + (m.Children.Count + 1);
            m.Children.Add(c);
        }
    }
 
    public class MasterObject
    {
        private string name;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (name != value)
                {
                    name = value;
                }
            }
        }
 
        public string NodeDesc
        {
            get
            {
                return "MasterObject";
            }
        }
 
        private BindingList<ChildObject> children;
        public BindingList<ChildObject> Children
        {
            get
            {
                return children;
            }
            set
            {
                children = value;
            }
        }
 
        public MasterObject()
        {
            children = new BindingList<ChildObject>();
        }
    }
 
    public class ChildObject
    {
        private string name;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (name != value)
                {
                    name = value;
                }
            }
        }
 
        public string NodeDesc
        {
            get
            {
                return "ChildObject";
            }
        }
 
        public ChildObject() { }
    }
}
Svett
Telerik team
 answered on 07 Mar 2013
2 answers
159 views
I'm following the example in the attached file here to drag and drop rows. In the PreviewDragDrop() event, the example casts e.DragInstance to a GridDataRowElement.

var rowElement = e.DragInstance as GridDataRowElement;
if (rowElement == null)
    return;

However, I never get a GridDataRowElement, I always get a SnapshotDragItem, so rowElement is always null.

How do I get the row element?
Jay
Top achievements
Rank 1
 answered on 07 Mar 2013
4 answers
250 views
Hello,
I have a datagridview and this have a imagecolumn and that image came from file. i can display image in grid but when i want to export datagrid value to pdf image doenst display in pdf.
Can you help me?
i attached example image from my grid and pdf.


Ivan Petrov
Telerik team
 answered on 07 Mar 2013
5 answers
235 views
I inherited a project from someone that used telerik 2010 q1.  I purchased the 2011 q3 version to upgrade it as part of the work i'm doing for them.  I see that there are several old controls that aren't part of 2011 and there's a conversion wizard that will upgrade them.  It seems to only be in 2011 q2 though.  Where can i download this?  In my account downloads, i can only get 2011 q3.

Thanks.
Nikolay
Telerik team
 answered on 07 Mar 2013
1 answer
101 views
Here is an easy one that has me stumped and I'm sure it will be very simple.

I use a Property Grid to display all the information about a selected record. ( displayed in a rad grid)

As the user selects records in the grid , I populate the property grid by defining a new PropertyStore based on the record selected and then setting this as the SelectedObject. Works well and thanks to your great support, its also Multi Language as well.

The glitch I have is if a user  selects a property ,( Which displays  the Property Description text at the bottom) and then selects a new line, the process of loading a new PropertyStore does not clear the  Property Description text at the bottom. 

How can I clear the  Property Description text?

See easy.. :)

Thanks as always

Rob
 


Stefan
Telerik team
 answered on 07 Mar 2013
1 answer
115 views

The title says everything - I am deploying an application and there are two files that are being created upon setup and load event. I am encrypting the app.config connection string using MSDN code that I found. However, when I deploy and run the program it creates two folders in my AppData/2.0/ folder structure with two ApplicationName.exe.config files. One of them is encrypted as you would expect, the other is not. I am not sure what is going wrong or how to prevent the application from creating two app.config files but especially the one that is not encrypted. Thank you!
Jack
Telerik team
 answered on 06 Mar 2013
23 answers
526 views
In my sample grid, I would like to allow grouping by the user, but add a count(fieldname) aggreagate to the groupbyexpression.
I found examples for the ASP.NET Grid but could not directly apply these to the WinForms Grid.

regards
erwin
Julian Benkov
Telerik team
 answered on 06 Mar 2013
1 answer
113 views
I use the RadDock.LoadFromXml(file), it works fine for all visible tool and document windows for the exception of hidden tab document windows.

When I hide all tab document windows, save to xml then restart my app and load from xml, they remain hidden but if at least one tab document window is not hidden, none of them remain hidden, they are all docked tab document again.

Looking at the xml file, it shows the DesiredDockState="Hidden" correctly on all tab documents that should remain hidden.
Anton
Telerik team
 answered on 06 Mar 2013
1 answer
49 views
Hi,

I am copy-pasting doubleclick.net generated ad content to radeditor and it strips part of it's content. The content looks as follows:
<script type="text/javascript">
var ord = window.ord || Math.floor(Math.random() * 1e16);
document.write('<script type="text/javascript" src="http://ad.doubleclick.net/xxxyyyzzz/adtarget;area=default;section=default;pos=fullbanner2;sz=728x90;ord=' + ord + '?"><\/script>');
</script>

radeditor actually match the ending script element in document.write function (line 3) and strips the last script element. It of course leads to js error and ad not working when rendering the content.

Pls, help how should I escape it or how to solve this in general.

Thanks,
Juraj
Rumen
Telerik team
 answered on 06 Mar 2013
12 answers
461 views
Hi, Telerik team.

I use Telerik Winform Q1 2012
I set property AutoFilter = true and FilterDescriptors  i set it filter on multicolumn with FilterOperator.Contains . When key press it auto filter then i select one row in EditorControl but SelectedValue set a wrong value.

I try to customize code in Demo Example's Telerik and have the same problem.

In namespace Telerik.Examples.WinControls.Editors.ComboBox.MultiColumnComboBox i customize Onload Method.
          protected override void OnLoad(EventArgs e)
          {
               base.OnLoad(e);
 
            NorthwindDataSet nwindDataSet = new NorthwindDataSet();
            CustomersTableAdapter customersTableAdapter = new CustomersTableAdapter();
            customersTableAdapter.Fill(nwindDataSet.Customers);
 
            this.radMultiColumnComboBox1.DataSource = nwindDataSet.Customers;
 
 
            //New My Code
            for (int i = 0 ; i < this.radMultiColumnComboBox1.EditorControl.Columns.Count ; i++)
            {
                var item = this.radMultiColumnComboBox1.EditorControl.Columns[i];
                string tmp= item.FieldName;
                FilterDescriptor descriptor = new FilterDescriptor(tmp ,FilterOperator.Contains ,null);             
                this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(descriptor);
                this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.LogicalOperator = FilterLogicalOperator.Or;
            }        
             
            //Old code
            //FilterDescriptor descriptor = new FilterDescriptor(this.radMultiColumnComboBox1.DisplayMember ,FilterOperator.StartsWith ,string.Empty);
            //this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(descriptor);
 
            this.radMultiColumnComboBox1.DropDownStyle = RadDropDownStyle.DropDown;
            // Filtering END
        }
Chris
Top achievements
Rank 1
 answered on 06 Mar 2013
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
Barcode
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Licensing
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
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?