How do I access a grid on a DocumentWindow?

2 posts, 0 answers
  1. Declan
    Declan  avatar
    47 posts
    Member since:
    May 2007

    Posted 23 Jul 2009 Link to this post

    My main form loads a RadDock and a toolWindow containing a PanelBar and RadList.

    On clicking items in the RadList a new DocumentWindow is opened. This window is a class which inherits from DocumentWindow.

    This loads the document window
    LogDocument documentLog = new LogDocument(); 
    documentLog.Text = documentTitle; 
    documentLog.CurrentFileId = selectedIndex; 
    documentLog.Load();  // Loads data into grid 
    AirFile.AddNewMostRecentFile(documentTitle, selectedIndex); 

    My inherited class (only some of it for brevity)
        class LogDocument : DocumentWindow 
            public LogDocument() 
            public void Load() 
            private void AddGridToForm() 
                RadTabStrip radTabStrip = new Telerik.WinControls.UI.RadTabStrip(); 
                TabItem tabGridItem = new Telerik.WinControls.UI.TabItem(); 
                TabItem tabDetailItem = new Telerik.WinControls.UI.TabItem(); 
                // radTabStrip1 
                radTabStrip.AutoScrollMargin = new System.Drawing.Size(0, 0); 
                radTabStrip.AutoScrollMinSize = new System.Drawing.Size(0, 0); 
                radTabStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(254))))); 
                radTabStrip.Dock = DockStyle.Fill; 
                radTabStrip.Location = new System.Drawing.Point(0, 0); 
                radTabStrip.Name = "radTabStrip"
                radTabStrip.ScrollOffsetStep = 5; 
                radTabStrip.TabScrollButtonsPosition = Telerik.WinControls.UI.TabScrollButtonsPosition.RightBottom; 
                radTabStrip.Text = "radTabStrip"
                // tabGridItem 
                tabGridItem.Alignment = System.Drawing.ContentAlignment.BottomLeft; 
                // tabItem1.ContentPanel 
                tabGridItem.ContentPanel.BackColor = System.Drawing.Color.Transparent; 
                tabGridItem.ContentPanel.CausesValidation = true
                tabGridItem.IsSelected = true
                tabGridItem.Margin = new System.Windows.Forms.Padding(4, 0, 0, 0); 
                tabGridItem.Name = "tabGridItem"
                tabGridItem.StretchHorizontally = false
                tabGridItem.Text = "Grid"
                // tabItem2 
                tabDetailItem.Alignment = System.Drawing.ContentAlignment.BottomLeft; 
                // tabItem2.ContentPanel 
                tabDetailItem.ContentPanel.BackColor = System.Drawing.Color.Transparent; 
                tabDetailItem.ContentPanel.CausesValidation = true
                tabDetailItem.Margin = new System.Windows.Forms.Padding(4, 0, 0, 0); 
                tabDetailItem.Name = "tabDetailItem"
                tabDetailItem.StretchHorizontally = false
                tabDetailItem.Text = "Item Detail"
                // TODO 
                // Add controls to show current row details in a form 
                grid.Dock = DockStyle.Fill; 
                grid.RowsChanged += new Telerik.WinControls.UI.GridViewCollectionChangedEventHandler(GridRowsChanged); 
                grid.DoubleClick += new System.EventHandler(GridDoubleClick); 
                // Add TabItems to TabStrip 
                radTabStrip.Items.AddRange(new Telerik.WinControls.RadItem[] { tabGridItem, tabDetailItem }); 
                // Add grid to tab 1 
                // Add tab strip to form 
            /// <summary> 
            /// Persist changes to current row to database. 
            /// </summary> 
            /// <param name="sender"></param> 
            /// <param name="e"></param> 
            private void GridRowsChanged(object sender, GridViewCollectionChangedEventArgs e) 

    In the constructor I add controls to the document including a RadGrid. When many documents are opened I have a UI similar to VisualStudio.

    My Main form has a menu containing a delete button. When this button is clicked I want to delete the current grid row on the current active window.

    My difficulty is that I cannot figure out how to reference the "delete item" code in the class LogWindow:
            public void DeleteRow() 
                // Delete code here 
                // then save changes to db 

    Any help would be appreciated.

  2. Boryana
    Boryana avatar
    330 posts

    Posted 27 Jul 2009 Link to this post

    Hello Declan,

    Thank you for contacting us.

    I managed to construct a sample project from the snippets in your post. In the implementation of DeleteRow() you can use the Remove() method to delete the current row. Please, note that before deleting it you have to check whether it exists and its RowInfo is GridViewDataRowInfo.

    Since, you have declared your DeleteRow() method as public, you should not encounter any issues, accessing it when handling the RadButton click. I have attached the sample project that demonstrates the described behavior.

    I hope this is helpful. If you have further questions, do not hesitate to write me back.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches
Back to Top