Solved

set the date controls backcolor

Posted on 2000-05-16
4
197 Views
Last Modified: 2010-05-02
Hi,

This is going to sound trivial, but it is an absolute requirement for a major project I work on to be able to set the background colour of the text portion of an MS Date control (from the Microsoft Windows Common Controls 6.0 3 group).

The control only supports the calendarbackcolor - which doesn't affect the background colour of the text portion.

How can I get around this ??
0
Comment
Question by:troywillmot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2815751
you may consider placing a textbox over the text portion of the control since it supports the backcolor and have the value of the date control be reflected in the textbox.  for example,

Private Sub DTPicker1_Change()
    Text1.Text = DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year
End Sub

Private Sub Form_Load()
    Text1.Text = DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year
End Sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2815754
on the same token you can use the masked edit control since that way you can format it the same as the date control which would allow the flexibility to let the user directly edit the text w/o needing a whole lot of extra code.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2815852
heres an idea using the Microsoft Masked Edit Control:

Option Explicit


Private Sub DTPicker1_Change()
    If DTPicker1.Month > 9 Then
        MaskEdBox1.Mask = "##/##/####"
    Else
        MaskEdBox1.Mask = "#/##/####"
    End If
    MaskEdBox1.Text = CStr(DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year)
End Sub

Private Sub Form_Load()
    With MaskEdBox1
        .Top = DTPicker1.Top
        .Left = DTPicker1.Width
        .Height = DTPicker1.Height
        .Width = DTPicker1.Width - 260
        .Left = DTPicker1.Left
        .BackColor = &H8080FF
    End With
    DTPicker1.Format = dtpCustom
    DTPicker1.CustomFormat = "dd/mm/yyyy"
    If DTPicker1.Month > 9 Then
        MaskEdBox1.Mask = "##/##/####"
    Else
        MaskEdBox1.Mask = "#/##/####"
    End If
    MaskEdBox1.Text = CStr(DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year)
End Sub
0
 
LVL 3

Author Comment

by:troywillmot
ID: 2815918
Thanks !

Thats the best answer I've had from anybody. I feel stupid for not having thought of it.

I'll build an activeX control that auto-hides/shows the text box when the control gets/looses focus, that way the date control can remain responsible for entering the value - but when the user isn't in the field the colour is shown because the text field will be visible.

I'd prefer the colour to be available all the time, but I like the masked edit controls date entry even less that the date controls enrty style. Besides which the date control supports more formats.

This gives me the best of both worlds, with little compromise.

Thanks again.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel VBA, find a string in a column, update a cell 7 117
Exit a vb6 apps when a calling it apps closes 15 63
Automatic Email Reminder 4 94
RUNRMTCMD from AS/400 13 130
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question