Is it possible to write the accompanying information next to the list with owner draw etc. on the auto-complete list of C#TextBox?

Asked 2 years ago, Updated 2 years ago, 39 views

TextBox or ComboBox

textBox1.AutoCompleteMode=AutoCompleteMode.SuggestAppend;
textBox1.AutoCompleteSource=AutoCompleteSource.CustomSource;

Assume that textBox1.AutoCompleteCustomSource contains the name of the address book.
If you put in a few letters of your name, it will be submitted, but I would like to include your phone number, address, etc. next to the name of the list box where the candidates for that time appear.
I'm wondering if I can use the owner draw for that information, but I don't know because Spy++ (32-bit/64-bit) included with Visual Studio 2008 fails to hook and doesn't get the Windows message well (I'm afraid I'll find out how to implement it).

Even if it's not an owner draw, it doesn't matter if you can do the same thing for the purpose you saw.
The point is that I want to do it like this (I make the image by editing).

Example AutoComplete

At this time, the red box can be another collection corresponding to the AutoCompleteCustomSource collection, or a list box (do you prefer a list view?) can be displayed under the text box if it is the same as the original purpose.

Is this quite difficult?

c# .net

2022-09-30 17:38

2 Answers

Add information directly to the right of AutoComplete.I don't think there is a function like this.

There is a way to adjust the font and character width well and do it manually.
Of course, the processing becomes complicated and troublesome.
If the width of the auto-completion is changed, you probably won't be able to follow it.

Next, instead of using AutoComplete, wpf + self-help list view.
I'm not saying it's auto-complete, and it's also troublesome to process it.
Display AutoComplete → Scroll with mouse wheel → AutoComplete area is often left blank.

To put it simply, wpf is a way to define what you want to see in the list view.
Usually, one item in the list view is text, and the rest is an icon?I could only display it, but I can freely set up the layout using wpf's data binding function.

Unfortunately, there is no way to do it directly, but I heard that there is a way to do it.


2022-09-30 17:38

When we looked at whether the owner draw was technically possible, Spy++ showed a form with AutoComplete and found that there were as many top-level windows as TextBox in the class called Auto-Suggest Dropdown.In principle, you should be able to draw an owner draw by retrieving the hWnd of the SysListView32 under it, under SetWindowsHookEx, and drawing it in the context obtained by Graphics.FromHwnd.However, I don't know which message is appropriate because WM_PAINT timing did not contain any text.


2022-09-30 17:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.