Solved

set the date controls backcolor

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 74
How to debug this code 7 61
message box in access 4 46
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 51
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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