두 개의 ListBoxes
이있는 양식이 있습니다. 나는 removeFromBoxWaitin
g 디렉토리에 새 파일을 만드는 것을 지켜봐야한다.
파일을 만든 후에는 파일을 인쇄 한 다음 목록 상자에 파일 이름을 추가해야합니다.
제 문제는 목록 상자가 업데이트되지 않는다는 것입니다. 항목은 실제로 추가되었지만 표시되지 않으며 나는 update()
도 시도했지만 작동하지 않았습니다. 그래서 어떤 조언을 부탁드립니다. 미리 감사드립니다.ListBox가 업데이트되지 않습니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using System.Threading;
using System.Configuration;
namespace PrntToKitchen
{
public partial class PrintFiles : DevExpress.XtraBars.Ribbon.RibbonForm
{
FileSystemWatcher filesWatcher = new FileSystemWatcher();
public void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
{
MessageBox.Show(e.Item.Name);
if (Properties.Settings.Default[e.Item.Name + "Read"].ToString().Length > 1 && Properties.Settings.Default[e.Item.Name + "ExtIn"].ToString().Length > 1)
{
filesWatcher.Path = Properties.Settings.Default[e.Item.Name + "Read"].ToString();
filesWatcher.Created += new System.IO.FileSystemEventHandler(eventG);
//filesWatcher.Deleted += new System.IO.FileSystemEventHandler(addToBoxFinished);
filesWatcher.EnableRaisingEvents = true;
}
}
public void eventG(object sender, FileSystemEventArgs e)
{
string CurrentPrinter = "";
string findPrt = e.FullPath.Substring(0, e.FullPath.Length-(e.Name.Length + 1));
string findPrtExt = e.Name.Substring(e.Name.LastIndexOf("."));
for (int i = 1; i <= Properties.Settings.Default.NumberOfPrinters; i++)
{
string testPrt = Properties.Settings.Default["Printer" + i + "Read"].ToString();
string testExt = Properties.Settings.Default["Printer" + i + "ExtIn"].ToString();
if (testPrt == findPrt && testExt == findPrtExt)
{
CurrentPrinter = "Printer" + i.ToString();
POSPrinter printer = new POSPrinter(Properties.Settings.Default["Printer" + i + "Port"].ToString(), (int)Properties.Settings.Default["Printer" + i + "Speed"]);
addToBoxWaiting(e.FullPath.ToString());
string file = e.FullPath;
printer.BeginPrint();
printer.PrintFile(file);
printer.EndPrint();
printer.Dispose();
if ((bool)Properties.Settings.Default[CurrentPrinter + "Delete"])
{
IsFileLocked(file);
System.IO.File.Delete(file);
}
else
{
System.IO.File.Move(file, Properties.Settings.Default[CurrentPrinter + "Store"] + "\\" + e.Name + Properties.Settings.Default[CurrentPrinter + "ExtOut"]);
}
removeFromBoxWaiting(e.FullPath.ToString());
addToBoxFinished(e.FullPath.ToString());
busy = false;
break;
}
}
}
void addToBoxWaiting(string text)
{
listBox1.Items.Add(text);
}
void removeFromBoxWaiting(string text)
{
listBox1.Items.Remove(text);
}
public void addToBoxFinished(string destination)
{
listBox2.Items.Add(destination);
}
}
}
@yordan이 가능를? – Adam
미안 해요. 나는 지금 그것을 할 것이다. – Jordan
바리템을 클릭하면 이벤트가 실행됩니까? – King