leocb / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
437 stars 132 forks source link

Combox box typing #310

Open NahumG10 opened 2 years ago

NahumG10 commented 2 years ago

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!

valimaties commented 2 years ago

I will try to make something...

valimaties commented 2 years ago

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 commented 2 years ago

Wow, that is awesome! Thank you so much for your efforts! This is perfect! Are you going to release a new update for the package or is it something local I can do for it to work?

‫בתאריך יום ה׳, 25 בנוב׳ 2021 ב-11:35 מאת ‪valimaties‬‏ <‪ @.***‬‏>:‬

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.

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 value. I've set this const to 500 milliseconds. 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, the filter icon will not be drawn.

Demo on MaterialSkinExemple: [image: FilterComboBox] https://user-images.githubusercontent.com/49796453/143413613-2b4a2ff0-03b9-42b1-9d10-4e59a51a2cf6.gif

How it is working? For example, I want to make a filter to "WHEN" word. I start typing: Key Time Filter W 0.3 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 0.3 W H 0.32 WH E 0.51 E N 0.28 EN Filter text = "EN"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/leocb/MaterialSkin/issues/310#issuecomment-979026672, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARKWAZKHAPYEMINN3KHETYDUNX7PZANCNFSM5IS7Z35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

valimaties commented 2 years ago

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 commented 2 years ago

Great, is it possible to not use the timer and reset when typing? and also show the text inside the search bar? Thanks!

‫בתאריך יום ה׳, 25 בנוב׳ 2021 ב-14:47 מאת ‪valimaties‬‏ <‪ @.***‬‏>:‬

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

Regards.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leocb/MaterialSkin/issues/310#issuecomment-979184750, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARKWAZKUKHEOGGHQE23KNUDUNYV5XANCNFSM5IS7Z35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

valimaties commented 2 years ago

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 commented 2 years ago

Yes I would like to type a letter and then the combobox will show items starting with that letter, them typing another letter will lead to filter items starting with the sequence of both letters and so on... And meanwhile show the letters typed if it is possible. I prefer it without timeout between typing.

On Thu, Nov 25, 2021, 17:28 valimaties @.***> wrote:

If you will reset on typing, it means the filter averytime will be the first letter. You maybe want to delete manually each character in filter, and you want to see filter text in Text value of combobox.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leocb/MaterialSkin/issues/310#issuecomment-979303058, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARKWAZIGRJHNFIPTQLQB6FLUNZIYRANCNFSM5IS7Z35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

valimaties commented 2 years ago

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 commented 2 years ago

That's perfect! Thanks a lot :)

orapps44 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Please create an issue with those error, to be solved