Click here to Skip to main content
15,903,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Remote Desktop Connection Pin
Baran M16-Jun-09 2:38
Baran M16-Jun-09 2:38 
QuestionTracking number of a given object stored in memory Pin
Nil_IQ15-Jun-09 23:59
Nil_IQ15-Jun-09 23:59 
AnswerRe: Tracking number of a given object stored in memory [modified] Pin
Luc Pattyn16-Jun-09 0:22
sitebuilderLuc Pattyn16-Jun-09 0:22 
JokeRe: Tracking number of a given object stored in memory Pin
OriginalGriff16-Jun-09 1:14
mveOriginalGriff16-Jun-09 1:14 
GeneralRe: Tracking number of a given object stored in memory Pin
Luc Pattyn16-Jun-09 1:26
sitebuilderLuc Pattyn16-Jun-09 1:26 
AnswerRe: Tracking number of a given object stored in memory Pin
Rob Philpott16-Jun-09 0:22
Rob Philpott16-Jun-09 0:22 
QuestionGroup Policy Management Pin
subhabasu15-Jun-09 23:52
subhabasu15-Jun-09 23:52 
AnswerRe: Group Policy Management Pin
Calla17-Jun-09 0:48
Calla17-Jun-09 0:48 
GeneralRe: Group Policy Management Pin
subhabasu17-Jun-09 18:24
subhabasu17-Jun-09 18:24 
QuestionSerial Ports problem Pin
izakiel15-Jun-09 23:16
izakiel15-Jun-09 23:16 
AnswerRe: Serial Ports problem Pin
shineqiujuan12-Jan-10 22:26
shineqiujuan12-Jan-10 22:26 
QuestionC# - sending mails Pin
treuveni15-Jun-09 22:04
treuveni15-Jun-09 22:04 
AnswerRe: C# - sending mails Pin
Christian Graus15-Jun-09 22:15
protectorChristian Graus15-Jun-09 22:15 
AnswerRe: C# - sending mails Pin
Luc Pattyn15-Jun-09 22:44
sitebuilderLuc Pattyn15-Jun-09 22:44 
AnswerRe: C# - sending mails Pin
Nil_IQ16-Jun-09 0:04
Nil_IQ16-Jun-09 0:04 
GeneralRe: C# - sending mails Pin
treuveni16-Jun-09 1:59
treuveni16-Jun-09 1:59 
QuestionRead Text Pin
arkiboys15-Jun-09 21:35
arkiboys15-Jun-09 21:35 
AnswerRe: Read Text Pin
himanshu256115-Jun-09 21:41
himanshu256115-Jun-09 21:41 
AnswerRe: Read Text Pin
Christian Graus15-Jun-09 22:16
protectorChristian Graus15-Jun-09 22:16 
GeneralRe: Read Text Pin
arkiboys16-Jun-09 0:35
arkiboys16-Jun-09 0:35 
QuestionProblem with data GridView C# Pin
PrakashPaul15-Jun-09 21:13
PrakashPaul15-Jun-09 21:13 
QuestionAdd Event to a CustomControl Pin
Sreedhar Kadiyala15-Jun-09 21:02
Sreedhar Kadiyala15-Jun-09 21:02 
Hi,

I'd created a Custom Control using MaskedTextBox and DateTimePicker. I'd written all the required validations and it is working fine. I'd even created a CustomEventHandler by using Delegate. The Problem is when I drag this control on to a form I could not find the CustomEventHandler to raise. Here is my Code. Can anyone suggest the solution. Thanks in Advance

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DateControl
{
public partial class UserDateControl : UserControl
{
private bool IsTrue;
private bool Err;
private string MskText;
public delegate void DateControlEventHandler();
[Category("Action"),Description("Fires when the Text Changed event Occurs!")]
public event DateControlEventHandler TextChanged;

public UserDateControl()
{
InitializeComponent();
}

protected virtual void OnTextChanged()
{
if (TextChanged != null)
{
TextChanged();
}
}

private void DTPicker_ValueChanged(object sender, EventArgs e)
{
string DTP;
if (DTPicker.Value.Day < 10)
DTP = "0" + DTPicker.Value.Day + "-";
else
DTP = DTPicker.Value.Day + "-";

if (DTPicker.Value.Month < 10)
DTP += "0" + DTPicker.Value.Month + "-";
else
DTP += DTPicker.Value.Month + "-";

DTP += DTPicker.Value.Year;

MskDateControl.Text = DTP;
}

[Category("DateControl Configuration"),Description("Whether the Control should accept more than Today's date?"),DefaultValue(false)]
public bool AcceptMoreThanToday
{
get { return IsTrue; }
set
{
IsTrue = value;
}
}

public string DateValue
{
get { return MskText; }
set
{
MskText = MskDateControl.Text;
}
}

private void MskDateControl_Validating(object sender, CancelEventArgs e)
{
if (MskDateControl.MaskFull == false)
{
errorProvider1.SetError(MskDateControl, "Please Check the Date!");
}
}

private void MskDateControl_TextChanged(object sender, EventArgs e)
{
if (MskDateControl.MaskFull == true)
{
Char[] ChrSep = new Char[] { '-' };
String[] SplitDate;
SplitDate = MskDateControl.Text.Split(ChrSep, 3);
int y = int.Parse(SplitDate.GetValue(2).ToString());
int d = int.Parse(SplitDate.GetValue(0).ToString());
int m = int.Parse(SplitDate.GetValue(1).ToString());
Err = false;

if (m > 12 || m <= 0)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Month!");
}
else if (y < 1900)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Year!");
}
else if (DateTime.DaysInMonth(y, m) < d)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Days!");
}
else if (d > 31 || d <= 0)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Days!");
}
else
{
Err = false;
errorProvider1.SetError(MskDateControl, "");
if (TextChanged != null)
{
OnTextChanged();
}
}

if (IsTrue == false && Err==false)
{
DateTime CnvDate = new DateTime(y, m, d);

DateTime SDate = DateTime.Today;

if (CnvDate > SDate)
{
errorProvider1.SetError(MskDateControl, "Date should not be more than Today's Date");
}
}
}
}

private void MskDateControl_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ') e.KeyChar = (char)0;
}

private void MskDateControl_Validated(object sender, EventArgs e)
{
if (Err == false && MskDateControl.MaskFull == true)
{
Char[] ChrSep = new Char[] { '-' };
String[] SplitDate;
SplitDate = MskDateControl.Text.Split(ChrSep, 3);
int y = int.Parse(SplitDate.GetValue(2).ToString());
int d = int.Parse(SplitDate.GetValue(0).ToString());
int m = int.Parse(SplitDate.GetValue(1).ToString());
DateTime EDate = new DateTime(y, m, d);
DTPicker.Value = EDate;
DateValue = MskDateControl.Text;
}
}
}
}

Sreedhar Kadiyala

AnswerRe: Add Event to a CustomControl Pin
DaveyM6915-Jun-09 22:16
professionalDaveyM6915-Jun-09 22:16 
GeneralRe: Add Event to a CustomControl Pin
Sreedhar Kadiyala15-Jun-09 23:04
Sreedhar Kadiyala15-Jun-09 23:04 
QuestionQR barcode decoder..... Pin
S K Y15-Jun-09 20:04
S K Y15-Jun-09 20:04 

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.