Files
Groupware/SubProject/FCOMMON/fLovDateList.cs
chikyun.kim 6ddd4736a3 .
2018-09-19 09:35:37 +09:00

56 lines
1.5 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 : Form
{
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)
{
}
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();
}
}
}