Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combox box typing #310

Open
NahumG10 opened this issue Nov 23, 2021 · 15 comments
Open

Combox box typing #310

NahumG10 opened this issue Nov 23, 2021 · 15 comments
Labels
enhancement New feature or request

Comments

@NahumG10
Copy link

Can you make an option to write in combobox? I need it to filter options in my combobox.
Meaning to have an option to change the dropdownstyle to drop down like simple combobox.

Thanks!

@orapps44 orapps44 added the enhancement New feature or request label Nov 23, 2021
@valimaties
Copy link

I will try to make something...

@valimaties
Copy link

valimaties commented Nov 25, 2021

I have made a kind of filter, but I must have approve of you to see if I will make a PR with this or not.
One known issue of this filter is that even if DropDown height is changed due to MaxDropDownItems value, the height itself will change only if we make a refresh of DropDown by setting it to false and back to true. This will create an ugly effect, so this code is commented in demo gif.

This filter will be available if FilterOnTyping property is set to true. It is made by capturing Key on KeyUp event of the control. It has a timer which will reset the filter if the time between keys pressed is greater than a constant property value, called FilterKeyDelay. I've set this const property, by default, to 500 milliseconds, but it can be increased, or decreased, as you want.
When a filter is made, a small filter icon is drawn in the up-left-most corner of control.
To delete filter, user must press Del or Backspace keys. In this case, Items collection will be populated with initial collection and the filter icon will not be drawn.

Demo on MaterialSkinExemple:
FilterComboBox

How it is working?
For example, I want to make a filter to "WHEN" word. I start typing:

Key      Time       Filter
W                     W
H        0.32         WH
E        0.41         WHE
N        0.24         WHEN  
Filter text = "WHEN"

but if I don't write quickly enough, the filter will be reset, as:

Key      Time       Filter
W                     W
H        0.32         WH
E        0.51         E
N        0.28         EN  
Filter text = "EN"

@NahumG10
Copy link
Author

NahumG10 commented Nov 25, 2021 via email

@valimaties
Copy link

Hi @NahumG10 .
I will make a PR, and if @orapps44 decides to merge it, you should merge the new master to your master.

Regards.

@NahumG10
Copy link
Author

NahumG10 commented Nov 25, 2021 via email

@valimaties
Copy link

valimaties commented Nov 25, 2021

If you will reset on typing, it means the filter text will be everytime the last key pressed, which is not good. This is the current approach of MaterialComboBox and Winform's ComboBox.
You maybe want to delete manually each character in filter, and you want to see filter text in Text value of combobox.

@NahumG10
Copy link
Author

NahumG10 commented Nov 26, 2021 via email

@valimaties
Copy link

I've added FilteringWithDelay property, which allow to autoreset filter, or not. If this is set to true, the behavior is as I explained above, if it is false, pressing keys Backspace or Del will delete the last char in the filter text. Filter text will be displayed on ComboBox before selecting an item from dropdown list.
Mention: filtering is case insensitive, typing case is UpperCase, dropdown will display all items starting with filter text!

FilterComboBox2

@NahumG10
Copy link
Author

That's perfect! Thanks a lot :)

@orapps44
Copy link
Collaborator

orapps44 commented Nov 26, 2021

Hi,

Currentely only DropDownStyle property = DropDownList is supported.
From my point of view, better approach would be to use DropDownStyle property =DropDown
This will makes control more compliant with .NET standard. and will allow standard text edition.

@valimaties
Copy link

Hi,

Currentely only DropDownStyle property = DropDownList is supported. From my point of view, better approach would be to use DropDownStyle property =DropDown This will makes control more compliant with .NET standard. and will allow standard text edition.

This means some work on repainting controls for DropDown style. Because if you comment lines from OnCreateControl and from constructor, the painting of control is showing a black background color. I think is a little bit of work.
If you have some time to implement it in DropDown style, you can do it, I don't know how to do it right now. This is what I was able to do 😐

@NahumG10
Copy link
Author

Maybe you can use all the code for filtering @valimaties did in a new control like materialCombobox2? And meanwhile enable the option to change drop-downstyle property of regular materialCombobox?

@valimaties
Copy link

No, personally, I don't want to create a new control only for a new function.
If this function is really a most-need for you, please create a new control based on MaterialComboBox and insert all the code I've inserted in my commits. This will helps you, till a good solution, best than I've done, is made by me or anyone else.
Cheers!

@NahumG10
Copy link
Author

NahumG10 commented Nov 27, 2021

Can you paste here the code for the new control based on MaterialComboBox and not combobox, IMaterialControl? I have some protection level errors of AnimationManager and DrawHelper classes and I can't find a way to solve them..

@valimaties
Copy link

Please create an issue with those error, to be solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants