57 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace FCOMMON
 | |
| {
 | |
|     public partial class fLovDateList : fBase
 | |
|     {
 | |
|         public string selectedDate = string.Empty;
 | |
|         public fLovDateList(List<string> dateList)
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             this.KeyPreview = true;
 | |
|             this.KeyDown += fLovDateList_KeyDown;
 | |
| 
 | |
|             this.listBox1.Items.Clear();
 | |
|             foreach (var dateStr in dateList)
 | |
|                 this.listBox1.Items.Add(dateStr);
 | |
|         }
 | |
|         private void __Load(object sender, EventArgs e)
 | |
|         {
 | |
|             EnsureVisibleAndUsableSize();
 | |
|         }
 | |
|      
 | |
|         void fLovDateList_KeyDown(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyCode == Keys.Escape) this.Close();
 | |
|         }
 | |
|         void selectItem()
 | |
|         {
 | |
|             selectedDate = string.Empty;
 | |
|             if (listBox1.Items.Count < 1) DialogResult = System.Windows.Forms.DialogResult.Cancel;
 | |
|             if (listBox1.SelectedItem == null) DialogResult = System.Windows.Forms.DialogResult.Cancel;
 | |
|             this.selectedDate = listBox1.SelectedItem.ToString();
 | |
|             DialogResult = System.Windows.Forms.DialogResult.OK;
 | |
|         }
 | |
| 
 | |
|         private void listBox1_DoubleClick(object sender, EventArgs e)
 | |
|         {
 | |
|             selectItem();
 | |
|         }
 | |
| 
 | |
|         private void listBox1_KeyDown(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|                 selectItem();
 | |
|         }
 | |
| 
 | |
|         
 | |
|     }
 | |
| }
 | 
