Click here to Skip to main content
15,880,543 members
Home / Discussions / C#
   

C#

 
AnswerRe: TextBox. How to Validate for Number?? Pin
Anonymous13-Oct-05 16:21
Anonymous13-Oct-05 16:21 
AnswerRe: TextBox. How to Validate for Number?? Pin
nps_ltv13-Oct-05 17:22
nps_ltv13-Oct-05 17:22 
AnswerRe: TextBox. How to Validate for Number?? Pin
Luis Alonso Ramos13-Oct-05 17:29
Luis Alonso Ramos13-Oct-05 17:29 
AnswerRe: TextBox. How to Validate for Number?? Pin
albCode13-Oct-05 20:56
albCode13-Oct-05 20:56 
QuestionComboBox - Set first display item in dropdown list Pin
--Ian13-Oct-05 5:51
--Ian13-Oct-05 5:51 
AnswerRe: ComboBox - Set first display item in dropdown list Pin
miah alom13-Oct-05 7:37
miah alom13-Oct-05 7:37 
GeneralRe: ComboBox - Set first display item in dropdown list Pin
--Ian13-Oct-05 8:49
--Ian13-Oct-05 8:49 
AnswerRe: ComboBox - Set first display item in dropdown list Pin
--Ian14-Oct-05 10:47
--Ian14-Oct-05 10:47 
I have a solution to my post, and here it is.

<br />
public class TimePicker : ComboBox<br />
{<br />
	bool m_fIsDropDown = false;<br />
	string m_strTime = string.Empty;<br />
	int m_nSelectedIndex = -1;<br />
	<br />
<br />
	public TimePicker() : base()<br />
	{<br />
	}<br />
<br />
	private void LoadTimes()<br />
	{<br />
		if (this.Items.Count < 1)<br />
		{<br />
			DateTime t = new DateTime(2005, 10, 11, 0, 0, 0, 0);<br />
			while (t < new DateTime(2005, 10, 12))<br />
			{<br />
				this.Items.Add(t.ToShortTimeString());<br />
				t = t.AddMinutes(30);<br />
			}<br />
		}<br />
	}<br />
<br />
	protected override void OnCreateControl()<br />
	{<br />
		base.OnCreateControl();<br />
<br />
		LoadTimes();<br />
	}<br />
<br />
	protected override void OnDropDown(EventArgs e)<br />
	{<br />
		base.OnDropDown(e);<br />
<br />
		m_strTime = this.Text;<br />
		DateTime dtmValue = DateTime.Now;<br />
		try <br />
		{<br />
			dtmValue = Convert.ToDateTime(m_strTime);<br />
		}<br />
		catch <br />
		{<br />
			return;<br />
		}<br />
<br />
		for (int i = 0; i < this.Items.Count; i++)<br />
		{<br />
			DateTime dtmItem = Convert.ToDateTime(this.Items[i].ToString());<br />
			if (dtmValue >= dtmItem && dtmValue < dtmItem.AddMinutes(30))<br />
			{<br />
				this.SelectedIndex = i;<br />
				m_nSelectedIndex = i;<br />
				break;<br />
			}<br />
		}<br />
<br />
		m_fIsDropDown = true;<br />
	}<br />
<br />
	protected override void OnMouseDown(MouseEventArgs e)<br />
	{<br />
		if (m_fIsDropDown == true)<br />
		{<br />
			this.SelectedIndex = m_nSelectedIndex;<br />
			this.Text = m_strTime;<br />
		}<br />
		else<br />
		{<br />
			base.OnMouseDown(e);<br />
		}<br />
	}<br />
<br />
	protected override void OnMouseUp(MouseEventArgs e)<br />
	{<br />
		if (m_fIsDropDown == true)<br />
		{<br />
			this.SelectedIndex = m_nSelectedIndex;<br />
			this.Text = m_strTime;<br />
			m_fIsDropDown = false;<br />
		}<br />
		else<br />
		{<br />
			base.OnMouseUp(e);<br />
		}		<br />
	}<br />
}	<br />



--IAN
Questionprocess security question Pin
devmaximus13-Oct-05 5:00
devmaximus13-Oct-05 5:00 
AnswerRe: process security question Pin
Dave Kreskowiak13-Oct-05 6:47
mveDave Kreskowiak13-Oct-05 6:47 
GeneralRe: process security question Pin
devmaximus13-Oct-05 11:02
devmaximus13-Oct-05 11:02 
QuestionA4 size Richtextbox Pin
AB777113-Oct-05 4:22
AB777113-Oct-05 4:22 
QuestionTerminate Application after a given time of inactivity? Pin
Gulfraz Khan13-Oct-05 4:14
Gulfraz Khan13-Oct-05 4:14 
AnswerRe: Terminate Application after a given time of inactivity? Pin
Luis Alonso Ramos13-Oct-05 17:32
Luis Alonso Ramos13-Oct-05 17:32 
GeneralRe: Terminate Application after a given time of inactivity? Pin
Gulfraz Khan14-Oct-05 0:55
Gulfraz Khan14-Oct-05 0:55 
QuestionCatching application start/close events Pin
Trickster-SWE13-Oct-05 2:58
Trickster-SWE13-Oct-05 2:58 
AnswerRe: Catching application start/close events Pin
XRaheemX13-Oct-05 3:50
XRaheemX13-Oct-05 3:50 
GeneralRe: Catching application start/close events Pin
Trickster-SWE13-Oct-05 4:00
Trickster-SWE13-Oct-05 4:00 
QuestionHow To add/Show icons to the main menu items? Pin
majidbhutta13-Oct-05 2:23
majidbhutta13-Oct-05 2:23 
AnswerRe: How To add/Show icons to the main menu items? Pin
Gulfraz Khan13-Oct-05 2:35
Gulfraz Khan13-Oct-05 2:35 
QuestionDo you know the answer? Pin
Gulfraz Khan13-Oct-05 2:22
Gulfraz Khan13-Oct-05 2:22 
AnswerRe: Do you know the answer? Pin
turbochimp13-Oct-05 20:17
turbochimp13-Oct-05 20:17 
QuestionCreate .EXE file Pin
zaboboa13-Oct-05 1:59
zaboboa13-Oct-05 1:59 
AnswerRe: Create .EXE file Pin
Dan Neely13-Oct-05 4:08
Dan Neely13-Oct-05 4:08 
AnswerRe: Create .EXE file Pin
Tom Larsen13-Oct-05 8:39
Tom Larsen13-Oct-05 8:39 

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.