Telerik Forums
UI for WinForms Forum
2 answers
156 views
Hi Telerik,

This isn't a question (unless you see ways to improve the class). Just giving a little back for all the help you guys have passed my way in the last year.

The class below allows a button to be placed in the Group Header cells of a grouped GridView and be able to subscribe to the button's clickevent. The event args pass back the GridViewGroupRowInfo. I'm using it to be able to identify and manipulate only the data rows associated with the particular group in question.

Hope some finds it useful
Regards
Ian

 
{
    public delegate void GroupHeaderCellButtonClickEventHandler(object sender, GroupHeaderButtonClickEventArgs e);
  
    public partial class CustomGridView : RadGridView
    {
        public event GroupHeaderCellButtonClickEventHandler GroupHeaderCellButtonClick;
  
        public CustomGridView()
        {
            InitializeComponent();
            base.CreateCell += new GridViewCreateCellEventHandler(CustomGridView_CreateCell);
        }
  
        void CustomGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
        {
  
            if (e.CellType == typeof(GridGroupContentCellElement) && e.Row.GetType() == typeof(GridGroupHeaderRowElement))
            {
                e.CellElement = new RadCustomGroupContentCell(e.Column, e.Row);
                RadCustomGroupContentCell cellElement = (RadCustomGroupContentCell)e.CellElement;
                cellElement.InternalGroupHeaderCellButtonClick+=new GroupHeaderCellButtonClickEventHandler(cellElement_InternalGroupHeaderCellButtonClick);
            }
        }
  
  
        void  cellElement_InternalGroupHeaderCellButtonClick(object sender, GroupHeaderButtonClickEventArgs e)
        {
            if (GroupHeaderCellButtonClick != null)
            {
                GroupHeaderCellButtonClick(sender, e);
            }
        }
  
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadGridView).FullName;
            }
            set
            { }
        }
  
        protected internal class RadCustomGroupContentCell : GridGroupContentCellElement
        {
            public event GroupHeaderCellButtonClickEventHandler InternalGroupHeaderCellButtonClick;
            RadButtonElement theButton;
  
            public RadCustomGroupContentCell(GridViewColumn column, GridRowElement row)
                : base(column, row)
            {
  
            }
  
            protected override void DisposeManagedResources()
            {
                theButton.Click -= new EventHandler(theButton_Click);
                base.DisposeManagedResources();
            }
  
            void theButton_Click(object sender, EventArgs e)
            {
                InternalGroupHeaderCellButtonClick(sender, new GroupHeaderButtonClickEventArgs((GridViewGroupRowInfo)this.RowInfo));
            }
  
            protected override void CreateChildElements()
            {
                base.CreateChildElements();
  
                theButton = new RadButtonElement();
                theButton.Click += new EventHandler(theButton_Click);
                theButton.Text = "Insert";
                theButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
                theButton.Image = Resources.InsertRow16;
                this.Children.Add(theButton);
            }
  
            protected override SizeF ArrangeOverride(SizeF finalSize)
            {
                SizeF size = base.ArrangeOverride(finalSize);
  
                float buttonX =2;
                float buttonY = 4;
  
                RectangleF buttonRectangle = new RectangleF(buttonX, buttonY, theButton.DesiredSize.Width + 4, theButton.DesiredSize.Height + 2);
                theButton.Arrange(buttonRectangle);
  
                float buttonAndTextX = theButton.DesiredSize.Width + 4;
                RectangleF clientRect = new RectangleF(buttonAndTextX + buttonX, 0, finalSize.Width - buttonAndTextX - buttonX, finalSize.Height + 4);
                this.layoutManagerPart.Arrange(clientRect);
  
                return size;
            }
  
            protected override Type ThemeEffectiveType
            {
                get
                {
                    return typeof(GridGroupContentCellElement);
                }
                set
                { }
            }
        }
    }
}


The Event args look like this although more could be added as needed I imagine

public class GroupHeaderButtonClickEventArgs:EventArgs
{
    public GridViewGroupRowInfo GroupRowInfo
    { get; set; }
    public GroupHeaderButtonClickEventArgs(GridViewGroupRowInfo groupRowInfo)
    {
        this.GroupRowInfo = groupRowInfo;
    }
}
Svett
Telerik team
 answered on 18 Oct 2011
3 answers
203 views
The MultiColumnComboBox currently selects the correct value in the popup when using the ENTER key. I want to achieve the same behavior with the TAB key but I haven't succeeded.

Also, if the user's text is not associated to any of the items, I want to empty the textbox so that he sees that's not a valid option.

Thanks!

Sample code :

using System.Collections.Generic;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
 
namespace MultiColumnComboAutoSelectWithTab
{
    public class RandomObject
    {
        public int Id { get; set; }
        public string FirstStuff { get; set; }
        public string SecondStuff { get; set; }
 
        public RandomObject(int id, string first, string second)
        {
            this.Id = id;
            this.FirstStuff = first;
            this.SecondStuff = second;
        }
 
    }
    public class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
            InitializeCustomComponent();
 
            var lst = new List<RandomObject>();
            lst.Add(new RandomObject(1, "Albert", "Stuff"));
            lst.Add(new RandomObject(2, "Alphonse", "Stuff"));
 
            this.radMultiColumnComboBox1.DataSource = lst;
        }
 
        private void InitializeCustomComponent()
        {
            this.radMultiColumnComboBox1.DisplayMember = "FirstStuff";
            this.radMultiColumnComboBox1.ValueMember = "Id";
 
            this.radMultiColumnComboBox1.EditorControl.Columns.Add(new GridViewTextBoxColumn("Id", "Id"));
            this.radMultiColumnComboBox1.EditorControl.Columns["Id"].IsVisible = false;
            this.radMultiColumnComboBox1.EditorControl.Columns.Add(new GridViewTextBoxColumn("FirstStuff", "FirstStuff"));
            this.radMultiColumnComboBox1.EditorControl.Columns["FirstStuff"].HeaderText = "First stuff";
            this.radMultiColumnComboBox1.EditorControl.Columns.Add(new GridViewTextBoxColumn("SecondStuff", "SecondStuff"));
            this.radMultiColumnComboBox1.EditorControl.Columns["SecondStuff"].HeaderText = "SecondStuff";
 
            this.radMultiColumnComboBox1.AutoFilter = true;
            this.radMultiColumnComboBox1.DropDownStyle = RadDropDownStyle.DropDown;
            this.radMultiColumnComboBox1.AutoSize = true;
            this.radMultiColumnComboBox1.AutoSizeDropDownToBestFit = true;
 
            var filter = new FilterDescriptor(this.radMultiColumnComboBox1.DisplayMember, FilterOperator.StartsWith, string.Empty);
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.FilterDescriptors.Add(filter);
        }
 
        /// <summary>
        /// Variable nécessaire au concepteur.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Nettoyage des ressources utilisées.
        /// </summary>
        /// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region AutoGeneratedStuff
 
        private void InitializeComponent()
        {
            this.radMultiColumnComboBox1 = new Telerik.WinControls.UI.RadMultiColumnComboBox();
            this.radTextBox1 = new Telerik.WinControls.UI.RadTextBox();
            ((System.ComponentModel.ISupportInitialize)(this.radMultiColumnComboBox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.radTextBox1)).BeginInit();
            this.SuspendLayout();
            //
            // radMultiColumnComboBox1
            //
            //
            // radMultiColumnComboBox1.NestedRadGridView
            //
            this.radMultiColumnComboBox1.EditorControl.BackColor = System.Drawing.SystemColors.Window;
            this.radMultiColumnComboBox1.EditorControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.radMultiColumnComboBox1.EditorControl.ForeColor = System.Drawing.SystemColors.ControlText;
            this.radMultiColumnComboBox1.EditorControl.Location = new System.Drawing.Point(0, 0);
            //
            //
            //
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.AllowAddNewRow = false;
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.AllowCellContextMenu = false;
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.AllowColumnChooser = false;
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.EnableGrouping = false;
            this.radMultiColumnComboBox1.EditorControl.MasterTemplate.ShowFilteringRow = false;
            this.radMultiColumnComboBox1.EditorControl.Name = "NestedRadGridView";
            this.radMultiColumnComboBox1.EditorControl.ReadOnly = true;
            this.radMultiColumnComboBox1.EditorControl.ShowGroupPanel = false;
            this.radMultiColumnComboBox1.EditorControl.Size = new System.Drawing.Size(240, 150);
            this.radMultiColumnComboBox1.EditorControl.TabIndex = 0;
            this.radMultiColumnComboBox1.Location = new System.Drawing.Point(81, 78);
            this.radMultiColumnComboBox1.Name = "radMultiColumnComboBox1";
            //
            //
            //
            this.radMultiColumnComboBox1.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren;
            this.radMultiColumnComboBox1.Size = new System.Drawing.Size(369, 20);
            this.radMultiColumnComboBox1.TabIndex = 0;
            this.radMultiColumnComboBox1.TabStop = false;
            this.radMultiColumnComboBox1.Text = "radMultiColumnComboBox1";
            //
            // radTextBox1
            //
            this.radTextBox1.Location = new System.Drawing.Point(81, 131);
            this.radTextBox1.Name = "radTextBox1";
            this.radTextBox1.Size = new System.Drawing.Size(330, 20);
            this.radTextBox1.TabIndex = 1;
            this.radTextBox1.TabStop = false;
            this.radTextBox1.Text = "radTextBox1";
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(498, 266);
            this.Controls.Add(this.radTextBox1);
            this.Controls.Add(this.radMultiColumnComboBox1);
            this.Name = "Form1";
            this.Text = "Form1";
            ((System.ComponentModel.ISupportInitialize)(this.radMultiColumnComboBox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.radTextBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
 
        }
 
        #endregion
 
        private Telerik.WinControls.UI.RadMultiColumnComboBox radMultiColumnComboBox1;
        private Telerik.WinControls.UI.RadTextBox radTextBox1;
    }
}
Francois
Top achievements
Rank 1
 answered on 18 Oct 2011
11 answers
790 views
hi,

I have Implemented Export to Excel for A RadGridView Content. It is working.
But the problem here is, I have child templetes also in my application.

Can you please tell me how to export The RadGridView content including Child templates
Or is there any property to be assigned.

Thank you.

regards,
Mahitha Madala.
Martin Vasilev
Telerik team
 answered on 17 Oct 2011
7 answers
238 views
Hi there,

I'd really like to make use of the GridViewMultiComboBoxColumn but I'm finding a few problems.

I have the DataSource property of the column bound to a collection of business objects.  That object has all sorts of properties and I really only want to show 2 of them.

I don't see any examples of the GridViewMultiComboBoxColumn in the shipping source code (Q3 2009 SP1) however I did find a couple of posts (here and here) of others trying to do something similar and it appears I need to customize the displayed Grid in the CellBeginEdit event.

A funny implementation detail of this is that since that event gets called everytime the user clicks on a row, I now need to add some class variable to determine if I've customized the grid otherwise the columns I add programmatically get added over and over...  overlooking that for the moment here's my questions.

Question 1:  My first issue is that when I click on the cell with the GridViewMultiComboBoxColumn, it suddenly shows me a Type name 'Telerik.WinControls.UI.GridViewDataRowInfo' instead of the DisplayMember.  Here's a screenshot.

Question 1.1: As a side note, why must a click twice in the cell to get the drop down to display?

Question 2:  My second issue is that when it displays the Grid, even though I've told it to only display 2 columns, it still makes space for all the properties.  Why is this?  It doesn't seem to matter if I call BestFitColumns().  Here's a screenshot.

I've uploaded my source code here for you to see.
Francois
Top achievements
Rank 1
 answered on 17 Oct 2011
2 answers
137 views
Hi Telerik

I'm trying to create a standout highlight in a treeview to indicate which document in a raddock has been selected. I have created a Custom document with a DocumentNode property which points to the node in the tree which relates to the document. I'm using the Active document changed event and a TreeViewElement.Update to attempt this. THe code works for the addition of a single document but gets stuck on the next added document and won't reformat the appropriate node when I change from one document to the other by clicking on the document window tab.

The key code snippets are below:
In Active Document changed

tvMPWorkspace.TreeViewElement.Update(RadTreeViewElement.UpdateActions.StateChanged);


In Node Formatting event

if (rDockModelPackage.DocumentManager.ActiveDocument != null && ((RadCustomDocumentWindow)rDockModelPackage.DocumentManager.ActiveDocument).DocumentNode == e.Node)
{
    e.NodeElement.BackColor = Color.PaleGoldenrod;
}
else
{
    e.NodeElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
}

As usual, all help gratefully received
Regards
Ian
Ian
Top achievements
Rank 1
 answered on 17 Oct 2011
2 answers
124 views
Hi
When i am droping an object from another control to ribbon, how do u know.. where did i drop my object, i mean.. on which button/gallery and what is that name and all


i have tried like this
Point pt = new Point(e.X, e.Y);
 if ((rbMosaique.GetChildAtPoint(pt) != null) &&
(rbM.GetChildAtPoint(pt).GetType() == typeof(Telerik.WinControls.UI.RadGalleryItem))


but it is always showing null


pelase help me 


Advance thanks


Regards
Hema
Peter
Telerik team
 answered on 17 Oct 2011
9 answers
246 views
Is there something broken about dragdrop in Q2 treeview?
I have a treeview where I have enabled 'AllowDragDrop' and 'AllowDrop'. However, the 'ItemDrag', 'DragStarted' and 'DragStarting' events aren't firing all all.

Is there something I'm doing wrong? The documentation makes it look easy!
I'm basically wanting to detect when a node from the first treeview is dragged into the second treeview.

Thanks,
Richard.
Svett
Telerik team
 answered on 17 Oct 2011
1 answer
226 views
Hi,

I am using RadListView in DetailView type and have 4 columns.  I would like to display an image before the text in the 3rd column depending on the data in that column.  The column holds a file name i.e myFile.pdf and I would like to make that a link that is clickable how do I do that?

I know this is twp questions into one but I really need a quick response and the Issue tracker site is not working at the moment

Thanks
H
Ivan Todorov
Telerik team
 answered on 17 Oct 2011
8 answers
160 views
Hello,
I want "four column headings" Merge to "1" header line.
is that possible?
Ivan Petrov
Telerik team
 answered on 17 Oct 2011
2 answers
221 views
I want to have a button in the filter row for cancelling all active filters.
Just like the Clear filters button in http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

Is this possible in winforms?
Dave
Top achievements
Rank 1
 answered on 15 Oct 2011
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?