6 Replies - 1941 Views - Last Post: 04 January 2012 - 10:21 AM Rate Topic: -----

#1 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: 11-March 11

Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 09:25 AM

Hello,

I am currently in a pickle trying to figure out how to select text in a DTP. I'm to have the DTP text box load up as a blank text box upon loading the form.

dtp.Value = Date.Now
dtp.CustomFormat = " " 



This successfully makes the DTP blank upon load however I am unable to figure out how to, when tabbing to the text box, it will select the textbox(as you would if it were a normal text box). Is this possible? I can't seem to figure out a way to do this without putting a blank textbox on top of it which I would really like to avoid. Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: Datetimepicker, making blank upon load but selecting nothing upon tabb

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,121
  • Joined: 12-June 08

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 09:46 AM

Is this in ASP.NET or a regular windows form? If it's the latter then the textbox's "enter" event coupled with a ".selectall" tends to work find.
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,356
  • Joined: 02-June 10

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 09:49 AM

If you've made the format " " and nothing is in the textbox then what are you expecting to display? There's nothing to select, there never can be anything to select because you formatted the display to a space. It won't matter what you type there because it will just get reformatted to a " " space just like you told it to do.
Was This Post Helpful? 0
  • +
  • -

#4 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: 11-March 11

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 09:56 AM

This is for a windows form, sorry should've specified.

And making the custom format " " is the only way I could've found to make the control empty upon loading the form. When the user clicks the dropdown calendar it will fill in the textbox with the date however I have not a clue on how to make the control load empty while having the control get selected/highlighted/any sort of hint that the control is selected when/if the user tabs to the control.

Thanks for the replies :)
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,121
  • Joined: 12-June 08

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 10:05 AM

The Datetime picker control (on a regular windows form) always needs a value.

Curious question - under what UI design are you needing this to *NOT* have a date when showing up?

You might be best with an empty textbox (empty) on top of your date time picker and when someone clicks on the textbox it goes invisible..
Was This Post Helpful? 1
  • +
  • -

#6 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,356
  • Joined: 02-June 10

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 10:10 AM

A DTP is never 'empty' or 'blank' or 'valueless'. It just isn't. It always has a value. That's the designed intent of the control.

Modi is right that you might want a textbox on top to produce this weird GUI you want. But you have to realize the DTP will still have a value.

If you want to be able to select the contents of the textbox then you won't want to make it invisible. Instead you'll have use it as your input and display. When a new value is entered in the textbox you can send that to the DTP.

But its a little clunky for my liking. Why do you *need* the DTP to be blank? That's just odd.
Was This Post Helpful? 1
  • +
  • -

#7 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 120
  • Joined: 11-March 11

Re: Datetimepicker, making blank upon load but selecting nothing upon tabb

Posted 04 January 2012 - 10:21 AM

It's in the requirements, I have no clue. It's hardly what I would call a good option ever.

I guess I'll have to put a textbox over it, I understand that it can never be null I was just hoping there was a quick, easy fix for this but that's never the case for anything. ;)

Thanks for all the help and all the replies :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1