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?
Visual Basic.NET* vb6C#Visual Basic Classic

Avatar of undefined
Last Comment
Chinmay Patel
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.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Isn't there a .Select() method you can call on the DTP control?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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
Avatar of Kelly Martens
Kelly Martens

ASKER

Chinmay its just a visual effect of selection bias is after here
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo