Solved

set the date controls backcolor

Posted on 2000-05-16
4
182 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now