Link to home
Start Free TrialLog in
Avatar of Kelly Martens
Kelly Martens

asked on

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?
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

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.
Isn't there a .Select() method you can call on the DTP control?
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).
Avatar of Kelly Martens
Kelly Martens

ASKER

Right I found that too. I'm trying to mimic what the textboxes are doing because boss wants the same results for enduser
Chinmay its just a visual effect of selection bias is after here
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial