1 Attachment(s)
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
http://img3.imageshack.us/img3/300/c...utonnotrig.png
and i want to have like you can see in attach.
button should move slightly to the left
thank you
Re: combobox and commandbutton in one control