Telerik Forums
UI for WinForms Forum
1 answer
501 views
I am binding objects to a hierarchy grid in code and when a change is made a child row the change is shown in the grid, however, the underlying data object is not updated.  I can manually apply the new value after edit to the object, but it seems like grid should be doing this for me.

public partial class Form1 : Form
    {
        private BindingList<Node> AllNodes = new BindingList<Node>();
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadData();
        }
 
        public void LoadData()
        {
            LoadAllNodes();
            grid.DataSource = AllNodes;
            LoadAllObjectColumns(grid.MasterTemplate);
            // Load child template
            GridViewTemplate template = new GridViewTemplate();
            LoadAllObjectColumns(template);
            grid.MasterTemplate.Templates.Add(template);
 
            GridViewRelation r = new GridViewRelation(grid.MasterTemplate, template);
            r.ChildColumnNames.Add("Children");
 
            grid.Relations.Add(r);
        }
 
        public void LoadAllNodes()
        {
            Node p1 = new Node("Parent 1", ItemStatus.None);
            Node n1 = new Node("Child 1", ItemStatus.None);
            Node n2 = new Node("Child 2", ItemStatus.None);
            p1.Children.Add(n1);
            p1.Children.Add(n2);
            AllNodes.Add(p1);
            Node p2 = new Node("Parent 2", ItemStatus.None);
            AllNodes.Add(p2);
        }
 
        public static void LoadAllObjectColumns(GridViewTemplate template)
        {
            template.Columns.Clear();
            template.EnableFiltering = true;
            template.AllowAddNewRow = false;
            template.AutoGenerateColumns = false;
 
            GridViewTextBoxColumn colName = new GridViewTextBoxColumn("Name");
            colName.HeaderText = "Name";
            colName.Name = "Name";
            template.Columns.Add(colName);
 
            GridViewComboBoxColumn colStatus = new GridViewComboBoxColumn("Status");
            colStatus.HeaderText = "Status";
            colStatus.Name = "Status";
            colStatus.DataSource = Enum.GetValues(typeof(ItemStatus)).Cast<ItemStatus>();
            template.Columns.Add(colStatus);
 
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        }
 
        public enum ItemStatus { None, New, Test, Complete };
 
        public class Node : INotifyPropertyChanged
        {
            public event PropertyChangedEventHandler PropertyChanged;
            protected void NotifyPropertyChanged(String info)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(info));
                }
            }
 
            private string name;
            private ItemStatus status;
            private BindingList<Node> children;
 
            public string Name
            {
                get
                {
                    return name;
                }
                set
                {
                    if (name != value)
                    {
                        name = value;
                        NotifyPropertyChanged("Name");
                    }
                }
            }
 
            public ItemStatus Status
            {
                get
                {
                    return status;
                }
                set
                {
                    if (status != value)
                    {
                        status = value;
                        NotifyPropertyChanged("Status");
                    }
                }
            }
 
            public BindingList<Node> Children
            {
                get
                {
                    return children;
                }
                set
                {
                    children = value;
                }
            }
 
            public Node(string name, ItemStatus status)
            {
                this.name = name;
                this.status = status;
                children = new BindingList<Node>();
            }
        }
    }


Julian Benkov
Telerik team
 answered on 21 Nov 2012
1 answer
159 views
i have 2 ddls and i want to populate the second one based on the value of the first one. so i went on to use a row filter to filter the data view to get the data i need on the second ddl but when the page loads i get the error operator & not defined for string "Select distinct Zones....." and data row view. i click ok on the dialog error box to close it and it goes on to open the form and the code actually works. so how do i get rid of the error

cmd.CommandText = "Select Distinct Zones.ZoneID,CustomerItems.CustomerID as CustomerID,Zones.Zone " & _
"From CustomerItems Inner Join Zones On Zones.ZoneID=CustomerItems.ZoneID " & _
"Inner Join StockItems On StockItems.StockID=CustomerItems.StockID Where CustomerItems.CustomerID='" & ddlCustomers.SelectedValue & "'"
da = New SqlDataAdapter(cmd)
da.Fill(ds, "Zones")

'Populate Zones
ddlZone.DisplayMember = "Zone"
ddlZone.ValueMember = "ZoneID"
ddlZone.DataSource = ds.Tables("Zones")


setup = False
If Not setup Then
Dim dv As DataView
dv = New DataView(ds.Tables("Zones"))
'dv.RowFilter = "CustomerID = '" & ddlCustomers.SelectedValue & "'"
dv.RowFilter = "[CustomerID] = " & ddlCustomers.SelectedValue
ddlZone.DataSource = dv
ddlZone.ValueMember = "ZoneID"
ddlZone.DisplayMember = "Zone"
setup = False
End If
Stefan
Telerik team
 answered on 21 Nov 2012
1 answer
284 views
HI,

is there any way that i can use Autocomplete with PropertyGridTextBoxEditor ?

Thanks ,
Ishara
Ivan Petrov
Telerik team
 answered on 20 Nov 2012
7 answers
235 views
Hello,

We currently have a field of our class that is the list of possible Texture that we can assign to a Sprite. It is a collection received by our Converter
class TextureConverter : ResourceConverter
    {
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            Type[] tType = new Type[] { typeof(Texture), typeof(TextureAtlas) };
            string[] tResource = ProjectManager.Singleton.CurrentProject.GetResourceNameListForType(tType, false);
            return new StandardValuesCollection(tResource);
        }
    }
And our class member goes like this:
[Category("Settings Sprite")]
        [DisplayName("Texture")]
        [Description("Current Texture")]
        [TypeConverter(typeof(TextureConverter))]
        public virtual string Texture
        {
            get
            {
                return mTextureCBValues;
            }
            set
            {
                if (mTextureCBValues != value)
                {
                    if (value == "")
                    {
                        ResetTexture();
                    }
                    else
                    {
                        Item tTex = ProjectManager.Singleton.CurrentProject.GetResourceByName(value, true, Name);
                        if (tTex is Texture)
                        {
                            mTextureCBValues = value;
                            SetTexture(tTex as Texture);
                        }
                        else if (tTex is TextureAtlas)
                        {
                            mTextureCBValues = value;
                            SetTextureAtlas(tTex as TextureAtlas);
                        }
                        else
                        {
                            SetStatus(Item.StatusState.ERROR, "Texture " + value + " is not found or invalid");
                            ResetTexture();
                        }
                    }
 
                    Refresh();
                    NotifyPropertyChanged();
                }
            }
        }

How is it possible to make that field so we can "search" (auto-suggestion) for the texture name we want?

Kaven
Ivan Petrov
Telerik team
 answered on 20 Nov 2012
0 answers
95 views

deleted  wrong forum

Dave
Top achievements
Rank 1
 asked on 20 Nov 2012
2 answers
238 views
Hi , I have to do a list of thumb images with on the left side a dropdown to select a print format
but whe I try to add a RadDropDownList
to this.Children in the CreateChildElements event I get this error "unknown method add(Telerik.WinControl.UI.RadDropDownList) of telerik.wincontrol.radElementCollection

here is the code
protected override void CreateChildElements()
         {
             base.CreateChildElements();
 
             this.stackLayout = new StackLayoutPanel();
             this.stackLayout.Orientation = Orientation.Horizontal;
 
             this.contentElement = new LightVisualElement();
               this.contentElement.StretchHorizontally = true;
             this.contentElement.MinSize = new Size(220, 2200);
             this.stackLayout.Children.Add(this.contentElement);
 
             imageElement = new clsBackDropItem(null,160,106);
             imageElement.ImageLayout = System.Windows.Forms.ImageLayout.Center;
             this.stackLayout.Children.Add(this.imageElement);
 
             this.buttonElement2 = new RadButtonElement();
             this.buttonElement2.Text = "Button2";
             this.stackLayout.Children.Add(this.buttonElement2);
 
             this.dd=new RadDropDownList();
             this.stackLayout.Children.Add(this.dd);
             this.Children.Add(this.stackLayout);

thanks in advance for any suggestion
ciao
Ivan Todorov
Telerik team
 answered on 20 Nov 2012
1 answer
194 views
Wondering if there is a simple way to do this...

I add an object to my entity context but I have not saved changes yet.  Therefore there is no ID or key associated to the entity.
I do however bind the grids datasource to the entities context.  The data appears in the grid in the appropriate file.

However, if I want to modify or delete a row whereas the entity hasn't been saved, I can't execute a LINQ query or something to get the record; again because it hasn't been saved yet.

Is there a way to get and assign the entity based upon the row selected?

dim detail as Invoice_Detail = gridview.selectedrow(0)....  Or something to that extent.

Thanks
Bob
Julian Benkov
Telerik team
 answered on 20 Nov 2012
2 answers
146 views
I have 2 lineseries charts, one under another.  The horizonal axes labels come from the same data set, however the vertical axes for both vary.

Since the labels for the vertical axes are different, the 0 points for each chart are not aligned.  I haven't been able to figure out how to get these to line up.  What am I missing?

I am trying to accomplish something like that is in the demo for ChartView -> Chart Types -> Stock Series \ Indicators except that I want the vertical axes on the right hand side.

Attached is a screen shot of the 2 graph unaligned.
Boryana
Telerik team
 answered on 20 Nov 2012
3 answers
291 views
When I retrieve a SortDescriptors.Expression from my RadGridView the column names are not escaped when they have a space in the name. The FilterDescriptors.Expression does this correctly (IMO) or at least returns what I expect.

For example, I have a RadGridView bound to a DataTable with the following columns: ID, Unit ID, Name
I have the grid sorted by the column 'Unit ID' and also filtered to include only records where 'Unit ID'=1 at run-time.
I then run the following commands:
string sort = this.myRadGridView.SortDescriptors.Expression;
Console.WriteLine(sort);
 
string filter = this.myRadGridView.FilterDescriptors.Expression;
Console.WriteLine(filter);

I get the following output:
Unit ID ASC
([Unit ID] = 1)

With the FilterDescriptors.Expression value I can insert that string directly  back into a SQL query with no issues. With the SortDescriptors.Expression I have to run an addional routine on the result before I can use it in a query.

I have a workaround I am using right now (simple string replace) but the inconsistant results were something I thought I should bring up here. Maybe the SortDescriptors could be changed to work more like the FilterDescriptors in the future? Anyway, this post is mainly an 'FYI' but if anyone has any comments or tips, they would be appreciated.
Julian Benkov
Telerik team
 answered on 20 Nov 2012
3 answers
200 views
Hi,

When I click the "Click here to add a new row" text on a grid, the new row is overlaid on the text and I insert values in place. The RowIndex of the new row is -1, and this allows me to differentiate between an insert and an edit,

If I call Rows.AddNew though it looks like the row is inserted and then edited, which means it is assigned a RowIndex and I can't now check whether this is an insert or update.

In the BeginEdit event, I check the RowIndex to determine whether we are inserting or editing as some of the columns are Insert Only as :

Dim rowindex As Integer = e.RowIndex
            If rowindex > -1 Then
                If CustomCheckForInsertOnly Then
                    e.Cancel = True
                    Exit Sub
                End If
            End If

This works fine for a click initiated insert, but doesn't for a programmatic insert as the RowIndex is now assigned. 

Is there a way to simulate the "Click here to add a new row" behaviour when calling Rows.AddNew, or alternatively another way to differentiate between an insert and an update in BeginEdit?

Thanks,

Mark.
Stefan
Telerik team
 answered on 20 Nov 2012
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
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
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?