Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: Invoking external application? Pin
sohighthesky8-Mar-09 4:39
sohighthesky8-Mar-09 4:39 
Questiondatagrideview Pin
sevda207-Mar-09 19:21
sevda207-Mar-09 19:21 
AnswerRe: datagrideview Pin
vinodkrebc7-Mar-09 21:42
vinodkrebc7-Mar-09 21:42 
QuestionRemoting in .NET 2.0 - still not getting it! Pin
caix7-Mar-09 16:30
caix7-Mar-09 16:30 
AnswerRe: Remoting in .NET 2.0 - still not getting it! Pin
aviadqwerty8-Mar-09 5:44
aviadqwerty8-Mar-09 5:44 
QuestionChange fore color of datetimepicker Pin
trinm19877-Mar-09 16:09
trinm19877-Mar-09 16:09 
AnswerRe: Change fore color of datetimepicker Pin
DaveyM698-Mar-09 0:53
professionalDaveyM698-Mar-09 0:53 
AnswerForeColor and BackColor Pin
DaveyM698-Mar-09 2:20
professionalDaveyM698-Mar-09 2:20 
I don't normally give 'full' code but I've had a play around to make sure the advice I gave earlier was correct, so I figured I may as well share.

This enables use of the BackColor as well as ForeColor. I've used the DropDownButton part of the ComboBox for ease. I haven't implemented any of the editing on the text part of the control that is available in the .Net supplied one as that isn't quite as trivial! I also haven't checked the Enabled state to alter the way it's drawn, and I haven't drawn any border around the control as I can't remember how to get the colors in use by the system. Blush | :O

So there's plenty left to do but it should give you a start.
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace MyControls
{
    public class MyDateTimePicker : DateTimePicker
    {
        public MyDateTimePicker()
            : base()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
        }

        [Browsable(true),
        EditorBrowsable(EditorBrowsableState.Always),
        DefaultValue(typeof(Color), "Window")]
        public override Color BackColor
        {
            get { return base.BackColor; }
            set { base.BackColor = value; }
        }

        [Browsable(true),
        EditorBrowsable(EditorBrowsableState.Always),
        DefaultValue(typeof(Color), "WindowText")]
        public override Color ForeColor
        {
            get { return base.ForeColor; }
            set { base.ForeColor = value; }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            StringFormat stringFormat = new StringFormat();
            stringFormat.LineAlignment = StringAlignment.Center;
            using (Brush brush = new SolidBrush(BackColor))
            {
                e.Graphics.FillRectangle(brush, 0, 0, ClientRectangle.Width, ClientRectangle.Height);
            }
            using (Brush brush = new SolidBrush(ForeColor))
            {
                e.Graphics.DrawString(Text, Font, brush, ClientRectangle, stringFormat);
            }
            Rectangle dropDownRectangle = new Rectangle(
                ClientRectangle.Width - Height, 0, Height, Height);
            if (ComboBoxRenderer.IsSupported)
                ComboBoxRenderer.DrawDropDownButton(e.Graphics, dropDownRectangle, ComboBoxState.Normal);
            else
                ControlPaint.DrawComboButton(e.Graphics, dropDownRectangle, ButtonState.Normal);
        }
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

Questionproblem with datagrid Pin
Shuaib wasif khan7-Mar-09 10:16
Shuaib wasif khan7-Mar-09 10:16 
AnswerRe: problem with datagrid Pin
Xmen Real 7-Mar-09 14:24
professional Xmen Real 7-Mar-09 14:24 
AnswerRe: problem with datagrid Pin
sohighthesky8-Mar-09 4:57
sohighthesky8-Mar-09 4:57 
Questionbluetooth functionality using franson bluetools (Pocket PC) [modified] Pin
Yanal_Adham7-Mar-09 8:58
Yanal_Adham7-Mar-09 8:58 
AnswerRe: bluetooth functionality using franson bluetools (Pocket PC) Pin
DaveyM697-Mar-09 10:22
professionalDaveyM697-Mar-09 10:22 
QuestionArray Sort Pin
mehdy_1377-Mar-09 8:43
mehdy_1377-Mar-09 8:43 
AnswerRe: Array Sort Pin
fly9047-Mar-09 8:57
fly9047-Mar-09 8:57 
AnswerRe: Array Sort [modified] Pin
harold aptroot7-Mar-09 8:59
harold aptroot7-Mar-09 8:59 
QuestionClick images with webcam using c# Pin
Umangj7-Mar-09 8:26
Umangj7-Mar-09 8:26 
AnswerRe: Click images with webcam using c# Pin
DaveyM697-Mar-09 10:26
professionalDaveyM697-Mar-09 10:26 
GeneralRe: Click images with webcam using c# Pin
Umangj7-Mar-09 10:29
Umangj7-Mar-09 10:29 
GeneralRe: Click images with webcam using c# Pin
DaveyM697-Mar-09 11:20
professionalDaveyM697-Mar-09 11:20 
AnswerRe: Click images with webcam using c# Pin
Eddy Vluggen8-Mar-09 2:35
professionalEddy Vluggen8-Mar-09 2:35 
QuestionVista or .NET remember? Access to System32 Pin
NorbertKl177-Mar-09 6:48
NorbertKl177-Mar-09 6:48 
AnswerRe: Vista or .NET remember? Access to System32 Pin
harold aptroot7-Mar-09 7:22
harold aptroot7-Mar-09 7:22 
GeneralRe: Vista or .NET remember? Access to System32 Pin
NorbertKl177-Mar-09 8:31
NorbertKl177-Mar-09 8:31 
GeneralRe: Vista or .NET remember? Access to System32 Pin
harold aptroot7-Mar-09 8:53
harold aptroot7-Mar-09 8:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.