Click here to Skip to main content
15,891,787 members
Home / Discussions / C#
   

C#

 
QuestionSet Image to Button Pin
KIDYA4-Nov-11 21:51
KIDYA4-Nov-11 21:51 
AnswerRe: Set Image to Button Pin
OriginalGriff4-Nov-11 22:16
mveOriginalGriff4-Nov-11 22:16 
GeneraloRe: Set Image to Button Pin
KIDYA4-Nov-11 23:32
KIDYA4-Nov-11 23:32 
GeneralRe: oRe: Set Image to Button Pin
OriginalGriff4-Nov-11 23:49
mveOriginalGriff4-Nov-11 23:49 
AnswerRe: Set Image to Button Pin
RaviRanjanKr5-Nov-11 5:32
professionalRaviRanjanKr5-Nov-11 5:32 
AnswerRe: Set Image to Button Pin
Mark Salsbery5-Nov-11 5:56
Mark Salsbery5-Nov-11 5:56 
QuestionWinForms Owner-Draw ComboBox Not Displaying Correctly Pin
Matt U.4-Nov-11 9:34
Matt U.4-Nov-11 9:34 
AnswerRe: WinForms Owner-Draw ComboBox Not Displaying Correctly Pin
Eddy Vluggen5-Nov-11 15:15
professionalEddy Vluggen5-Nov-11 15:15 
As an alternative solution;

Take a Panel with the height of a TextBox. Put a TextBox on there, and position it on the left, leaving 23 dull pixels from the Panel visible.

You'd get something along these lines;
C#
public partial class MyComboThingy : Panel
{
    const int arrowLen = 23;
    Panel dropDownPanel = new Panel();
    bool open = false;
    TextBox TextBoxValue = new TextBox();

    public MyComboThingy()
    {
        this.MaximumSize = new Size(9999999, this.Height);
        this.makeSmaller();
        this.Controls.Add(TextBoxValue);
        TextBoxValue.Location = new Point(0, 0);
        makeSmaller();
        Paint += this._Paint;
    }

    void makeSmaller()
    {
        TextBoxValue.Width = Width - arrowLen;        
    }

    protected override void OnResize(EventArgs e)
    {
        base.OnResize(e);
        makeSmaller();
    }
    protected override void OnMouseClick(MouseEventArgs e)
    {
        base.OnMouseClick(e);
        open = !open;

        if (open)
        {
            dropDownPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            dropDownPanel.Parent = this.Parent;
            dropDownPanel.BackColor = Color.White;
            dropDownPanel.Location = new Point(
                this.Location.X, this.Location.Y + this.Height);
            dropDownPanel.Size = new Size(this.Width, 150);
            dropDownPanel.BringToFront();
            dropDownPanel.Show();
        }
        else
        {
            dropDownPanel.Hide();
        }
    }

    private void _Paint(object sender, PaintEventArgs e)
    {
        Rectangle myRect = new Rectangle(
            e.ClipRectangle.X + e.ClipRectangle.Width - arrowLen,
            e.ClipRectangle.Y,
            arrowLen, 
            e.ClipRectangle.Height);
        try
        {
            ControlPaint.DrawComboButton(
                e.Graphics, 
                myRect, 
                open ? ButtonState.Pushed : ButtonState.Normal);
        }
        catch
        { }
    }
}

Bastard Programmer from Hell Suspicious | :suss:

GeneralRe: WinForms Owner-Draw ComboBox Not Displaying Correctly Pin
Matt U.5-Nov-11 16:31
Matt U.5-Nov-11 16:31 
QuestionIs there a tool to keep track of user objects consumed by UI controls for a process ? Pin
Member 83746244-Nov-11 2:03
Member 83746244-Nov-11 2:03 
AnswerRe: Is there a tool to keep track of user objects consumed by UI controls for a process ? Pin
Pete O'Hanlon4-Nov-11 2:06
mvePete O'Hanlon4-Nov-11 2:06 
GeneralRe: Is there a tool to keep track of user objects consumed by UI controls for a process ? Pin
Nish Nishant4-Nov-11 4:31
sitebuilderNish Nishant4-Nov-11 4:31 
GeneralRe: Is there a tool to keep track of user objects consumed by UI controls for a process ? Pin
Richard MacCutchan4-Nov-11 22:18
mveRichard MacCutchan4-Nov-11 22:18 
Questioninserting image into a table at runtime Pin
rahul honey3-Nov-11 22:03
rahul honey3-Nov-11 22:03 
AnswerRe: inserting image into a table at runtime Pin
Pete O'Hanlon3-Nov-11 22:10
mvePete O'Hanlon3-Nov-11 22:10 
GeneralRe: inserting image into a table at runtime Pin
moxwose3-Nov-11 22:34
moxwose3-Nov-11 22:34 
GeneralRe: inserting image into a table at runtime Pin
rahul honey3-Nov-11 22:59
rahul honey3-Nov-11 22:59 
GeneralRe: inserting image into a table at runtime Pin
Pete O'Hanlon3-Nov-11 23:29
mvePete O'Hanlon3-Nov-11 23:29 
GeneralRe: inserting image into a table at runtime Pin
rahul honey4-Nov-11 0:59
rahul honey4-Nov-11 0:59 
GeneralRe: inserting image into a table at runtime Pin
Pete O'Hanlon4-Nov-11 1:24
mvePete O'Hanlon4-Nov-11 1:24 
GeneralRe: inserting image into a table at runtime Pin
rahul honey4-Nov-11 1:40
rahul honey4-Nov-11 1:40 
GeneralRe: inserting image into a table at runtime Pin
Pete O'Hanlon4-Nov-11 2:04
mvePete O'Hanlon4-Nov-11 2:04 
GeneralRe: inserting image into a table at runtime Pin
rahul honey4-Nov-11 2:16
rahul honey4-Nov-11 2:16 
AnswerRe: inserting image into a table at runtime Pin
Luc Pattyn4-Nov-11 2:25
sitebuilderLuc Pattyn4-Nov-11 2:25 
QuestionHow to create a style for a combobox in c# Pin
Arunkumar.Koloth3-Nov-11 7:14
Arunkumar.Koloth3-Nov-11 7:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.