This is a migrated thread and some comments may be shown as answers.

Footer and Header in DropDownList

5 Answers 131 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Oren
Top achievements
Rank 1
Oren asked on 28 Apr 2011, 10:01 PM
Hello,

Is it possible to create a header and footer for dropdownlist control,
and to insert controls to it?
exactly like in the asp.net ajax combobox control.

Thanks,
Oren

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 03:00 PM
Hello Oren,

Just create a custom control, dock other controls to the top + bottom, and dock the dropdownlist to fill.

Something like this:
using System.ComponentModel;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        var customDropDownList = new CustomDropDownList();
        var label = new RadLabel();
        label.Text = "Header";
        customDropDownList.HeaderControl = label;
        label = new RadLabel();
        label.Text = "Footer";
        customDropDownList.FooterControl = label;
        this.Controls.Add(customDropDownList);
        customDropDownList.Dock = DockStyle.Fill;
    }
}
 
[ToolboxItem(true)]
public class CustomDropDownList : RadControl
{
    private Control headerControl;
 
    private Control footerControl;
 
    private RadDropDownList customDropDownList;
 
    public CustomDropDownList()
    {
        customDropDownList = new RadDropDownList();
        this.Controls.Add(customDropDownList);
        customDropDownList.Dock = DockStyle.Fill;
    }
 
    public Control HeaderControl
    {
        get { return headerControl; }
 
        set
        {
            if (headerControl != value)
            {
                CleanupControl(headerControl);
                headerControl = value;
                OnControlChanged(headerControl, true);
            }
        }
    }
 
    public Control FooterControl
    {
        get { return footerControl; }
        set
        {
            if (footerControl != value)
            {
                CleanupControl(footerControl);
                footerControl = value;
                OnControlChanged(footerControl, false);
            }
        }
    }
 
    private void OnControlChanged(Control control, bool header)
    {
        this.Controls.Add(control);
        control.Dock = header ? DockStyle.Top : DockStyle.Bottom;
        this.Controls.SetChildIndex(control, header ? 1 : 2);
    }
 
    private void CleanupControl(Control control)
    {
        if (control == null)
        {
            return;
        }
 
        this.Controls.Remove(control);
        control.Dispose();
        control = null;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Peter
Telerik team
answered on 04 May 2011, 09:23 AM
Hi all,

Emanuel, thank you for your suggestion.

Oren, please check the help article suggested by Emanuel. It describes how to create a custom control.
Please do not hesitate to contact us if you have further questions.

Greetings,
Peter
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Oren
Top achievements
Rank 1
answered on 16 May 2011, 03:50 PM
Hi,

I just copied and run the suggested code and i didn't get the desire behaviour.(see image attached),
My request is to build a custom control from RadDropDownList (to inherite RadDropDownList ),
and to add header/footer with buttons (asp buttons) that could be functionality.

The main idea is to add radtreeview inside the dropdown exactly like i did in asp.net ajax.

Please see the attached images and help me to mimic the custom server control i did in asp.net ajax.

I use Telerik Controls Q1 2011

Thank's
Oren
0
Emanuel Varga
Top achievements
Rank 1
answered on 16 May 2011, 03:56 PM
Hello again Oren,

This is a totally different thing, and i would suggest again a different approach.
I would just suggest using a splitButton for this, for the look and feel with that down arrow, and then creating your own custom form which you will be showing when the user clicks on that button, simulating a dropdown but doing something totally different, and then you can create that form however you would like.

I hope you understood what i'm trying to say here.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Boryana
Telerik team
answered on 19 May 2011, 11:35 AM
Hi all,

Emanuel, thank you very much for your suggestion.

Oren, please refer to the attached sample project. I hope it illustrates the desired behavior. In case you have further queries, do not hesitate to contact us.

Regards,
Boryana
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
DropDownList
Asked by
Oren
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Peter
Telerik team
Oren
Top achievements
Rank 1
Boryana
Telerik team
Share this question
or