combobox and commandbutton in one control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: combobox and commandbutton in one control

Threaded View

  1. #1
    Join Date
    Jan 2007
    Posts
    11

    Question combobox and commandbutton in one control

    hello everyone
    i want to have a control with combobox and a button like you see in the attachment.
    i have already written these codes but i cannot move the button bit to left. anyone has an idea how should i get like in the attach?

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace project
    {
        public partial class ComboBoxWithButton : ComboBox
        {
    
            public event EventHandler TextChangedAfterValidation;
    
            public Form parentForm;
    
    
            private bool textChanged = false;
    
    
            public bool _textChanged { get { return textChanged; } }
    
    
            public ComboBoxWithButton()
            {
                InitializeComponent();
            }
    
            public virtual event EventHandler ClickButton
            {
                add
                {
                    this.button1.Click += value;
                }
                remove
                {
                    this.button1.Click -= value;
                }
            }
            protected override void OnCreateControl()
            {
                if (!this.Controls.Contains(this.button1))
                {
                    this.Controls.Add(this.button1);
                    
    
                }
    
                base.OnCreateControl();
            }
            private void OnMouseEnter(object sender, EventArgs e)
            {
                if (sender is Button)
                {
                    this.button1.Cursor = Cursors.Default;
                }
                else
                {
                    this.Cursor = Cursors.IBeam;
                }
    
            }
    
    
    
    
    
            protected override void OnPaint(PaintEventArgs pe)
            {
                base.OnPaint(pe);
            }
    
       
    
    
    
            public virtual void TextModified()
            {
    
    
            }
    
    
    
         
    
           
    
            private void button1_Click(object sender, EventArgs e)
            {
                btn1click();
            }
    
    
            public virtual void btn1click()
            {
    
                //MessageBox.Show("intern");
            
            }
    
            private void ComboBoxWithButton_KeyUp(object sender, KeyEventArgs e)
            {
                if (e.KeyValue == 13)
                {
                    ComboBoxWithButton_Validated(sender, e);
                }
            }
    
            private void ComboBoxWithButton_TextChanged(object sender, EventArgs e)
            {
                this.textChanged = true;
            }
    
            private void ComboBoxWithButton_Validated(object sender, EventArgs e)
            {
                if (this.textChanged)
                {
    
                    TextModified();
    
    
                    if (parentForm != null)
                    {
                        if (parentForm.GetType() == typeof(frmBetalingenBeheer))
                        {
                            ((frmBetalingenBeheer)parentForm).NaValidatietxtKlantFilter();
                        }
                        else
                        {
                            MessageBox.Show("  parentForm not linked");
                        }
                    }
    
    
                    if (this.TextChangedAfterValidation != null)
                        this.TextChangedAfterValidation(this, new EventArgs());
    
    
    
                    this.textChanged = false;
    
                }
                else return;
            }
    
    
        }
    }
    so i have here 2 controls (combobox and button)
    button is docked to right
    so i have something like this now



    and i want to have like you can see in attach.
    button should move slightly to the left
    thank you
    Attached Images Attached Images  
    Last edited by djramc; March 15th, 2012 at 04:44 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center