Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

set the date controls backcolor

Posted on 2000-05-16
4
Medium Priority
?
200 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 600 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
Suggested Courses

722 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