Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: QR barcode decoder..... Pin
DidiKunz15-Jun-09 22:06
DidiKunz15-Jun-09 22:06 
QuestionDatetime problem Pin
Pankaj Saha15-Jun-09 20:01
Pankaj Saha15-Jun-09 20:01 
AnswerRe: Datetime problem Pin
SeMartens15-Jun-09 21:01
SeMartens15-Jun-09 21:01 
AnswerRe: Datetime problem Pin
Vikram A Punathambekar15-Jun-09 21:36
Vikram A Punathambekar15-Jun-09 21:36 
Questionwhat does a Object value return? Pin
svt gdwl15-Jun-09 19:32
svt gdwl15-Jun-09 19:32 
AnswerRe: what does a Object value return? Pin
SeMartens15-Jun-09 21:46
SeMartens15-Jun-09 21:46 
QuestionNode.Tag Pin
LTMKH15-Jun-09 19:24
LTMKH15-Jun-09 19:24 
AnswerRe: Node.Tag Pin
DaveyM6915-Jun-09 21:01
professionalDaveyM6915-Jun-09 21:01 
GeneralRe: Node.Tag Pin
LTMKH16-Jun-09 0:26
LTMKH16-Jun-09 0:26 
Questionsystem.io.filenotfoundexception from using WaveFormat structure Pin
tjeffries15-Jun-09 15:49
tjeffries15-Jun-09 15:49 
AnswerRe: system.io.filenotfoundexception from using WaveFormat structure Pin
Dave Kreskowiak15-Jun-09 16:31
mveDave Kreskowiak15-Jun-09 16:31 
GeneralRe: system.io.filenotfoundexception from using WaveFormat structure Pin
tjeffries15-Jun-09 16:52
tjeffries15-Jun-09 16:52 
GeneralRe: system.io.filenotfoundexception from using WaveFormat structure Pin
tjeffries15-Jun-09 18:39
tjeffries15-Jun-09 18:39 
GeneralRe: system.io.filenotfoundexception from using WaveFormat structure Pin
molesworth15-Jun-09 23:21
molesworth15-Jun-09 23:21 

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.