Convert vb6 Selection Code

In vb6 this will select the text of two textboxes.

Public Sub SelectEntireText(txt_box As TextBox)

    txt_box.SelStart = 0
    txt_box.SelLength = Len(txt_box.Text)

End Sub

In C# I need to do the same but with a datetimepicker control. (The text representation of the date). How could I do this?
Kelly MartensAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
Hi Kelly,

I am not sure if it is the same with DateTimePicker. I would like to know what exactly you are trying to do after selecting the text?

Please refer to: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datetimepicker.text?view=netframework-4.7.2

Regards,
Chinmay.
Éric MoreauSenior .Net ConsultantCommented:
Isn't there a .Select() method you can call on the DTP control?
Éric MoreauSenior .Net ConsultantCommented:
I just tried and the .Select() method does not have the expected behavior.

This is surely because the DTP control has been overloaded to react to the up and down arrows to change the selected part (which is highlighted).
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Kelly MartensAuthor Commented:
Right I found that too. I'm trying to mimic what the textboxes are doing because boss wants the same results for enduser
Kelly MartensAuthor Commented:
Chinmay its just a visual effect of selection bias is after here
Éric MoreauSenior .Net ConsultantCommented:
but doesn't really make sense because when you are working with a textbox you are working with only one of its parts at a single time.
Chinmay PatelChief Technical NinjaCommented:
Hi Kelly,

I think I can do some research in the area - but trust me - I do not have a good feeling about it. If that does not work out, are you Ok with a custom control?

PS: I love to do hac-n-slash solution, heck my entire career is built around those but this one :P...  I don't think I would recommend you or anyone to go through it.

Regards,
Chinmay.
Chinmay PatelChief Technical NinjaCommented:
Hi Kelly,

DateTimePicker is an ActiveX control which has many other sub controls wrapped inside a container. I would not want to dive further in this.
If you want to do it, you might be able to do it via reflection.

If your boss does not agree then only way out is for you to make a UserControl which can provide the behavior you need or come up with other visual hacks, for example, hide the entire control, show a textbox and set its Text property to what user has selected in DateTimePicker and then select that text. If it was just to copy text on the clipboard you can easily get the values by using Text or Value property of DateTimePicker.

Regards,
Chinmay.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.