I'm currently working on a WinForms app, and I've just found out the dropdown area of an autocomplete-enabled textBox cannot have its font size changed. I've read an alternative would be using a WPF element host with an AutoCompleteBox (From WPFToolkit) and use interop to have it shown on my WFA.
Mind it's the very first time I'm working with interop. Originally I had the following textbox:
And I'd also need this event for future reasons:
I've managed to add an autocompletebox via interop:
However, I'd need to detect changes to the entered text. How can I achieve that through interop?
EDIT:
I manually added
Worked flawlessly.
Visual Studio doesn't do everything I need automagically. =)
Mind it's the very first time I'm working with interop. Originally I had the following textbox:
C#:
AutoCompleteStringCollection coll = new AutoCompleteStringCollection();
PDV.FDBDataSet.TB_STOCKDataTable dt = new PDV.FDBDataSet.TB_STOCKDataTable();
tB_STOCKTableAdapter1.Fill(dt);
foreach (DataRow row in dt)
{
//MessageBox.Show(row["DESCRIPTION"].ToString());
coll.Add(row["DESCRIPTION"].ToString());
_dt.Add(row["DESCRIPTION"].ToString());
}
textBox1.AutoCompleteCustomSource = coll;
And I'd also need this event for future reasons:
C#:
private void textBox1_TextChanged(object sender, EventArgs e)
{
Regex rgx = new Regex(@"(\d+\*)");
if (rgx.IsMatch(textBox1.Text))
{
txb_Qtde.Text = textBox1.Text.TrimEnd('*');
textBox1.Clear();
}
}
I've managed to add an autocompletebox via interop:
C#:
List<string> _dt = new List<string>();
private void Caixa_Load(object sender, EventArgs e)
{
ACBox.FontSize = 16;
ACBox.FontFamily = new System.Windows.Media.FontFamily("Segoe UI");
WPFHost1.Child = ACBox;
ACBox.MinimumPopulateDelay = 100;
ACBox.MinimumPrefixLength = 1;
ACBox.ItemsSource = _dt;
}
However, I'd need to detect changes to the entered text. How can I achieve that through interop?
EDIT:
I manually added
C#:
this.ACBox.TextChanged += new System.Windows.RoutedEventHandler(this.ACBox_TextChanged);
Visual Studio doesn't do everything I need automagically. =)
Last edited: