txt 파일에 들어있는 데이터의 다른 부분을 다른 목록 상자 (양식의 다른 탭에 있음)에 표시하여 사용자가 특정 데이터 블록을 볼 수있게해야합니다. . 관심있는 txt 파일에 포함 된텍스트 파일을 목록 상자 모음으로 읽어들입니다.
데이터는 다음과 같습니다
G30:39:03:31 JG06
G32:56:36:10 JG04
G31:54:69:52 JG04
G36:32:53:11 JG05
G33:50:05:11 JG06
G39:28:81:21 JG01
G39:22:74:11 JG06
G39:51:44:21 JG03
G39:51:52:22 JG01
G39:51:73:21 JG01
G35:76:24:20 JG06
G35:76:55:11 JG01
G36:31:96:11 JG02
G36:31:96:23 JG02
G36:31:96:41 JG03
그것을 :) 훨씬 더하지만
별도의리스트 박스는 첫 번째 정수 쌍 경기의 유일한 선을 포함합니다 그 목록 상자의 이름. 예를 들어, "G32"를 시작하는 모든 행은 G32 목록 상자에 추가됩니다.
나는 코드가 같은 시작할 것이라고 생각한다
private void ReadToBox()
{
FileInfo file = new FileInfo("Jumpgate List.JG");
StreamReader objRead = file.OpenText();
while (!objRead.EndOfStream)
을하지만 난 아직 분류지고의 측면에서 어디서부터 시작 모르겠어요.
어떤 도움이 필요합니까? 당신을 위해 몇 가지 대표 있어요 : D
편집 :
private void ViewForm_Load(object sender, EventArgs e)
{
this.PopulateListBox(lstG30, "G30", ("Jumpgate List.JG"));
this.PopulateListBox(lstG31, "G31", ("Jumpgate List.JG"));
this.PopulateListBox(lstG32, "G32", ("Jumpgate List.JG"));
this.PopulateListBox(lstG33, "G33", ("Jumpgate List.JG"));
this.PopulateListBox(lstG34, "G34", ("Jumpgate List.JG"));
this.PopulateListBox(lstG35, "G35", ("Jumpgate List.JG"));
this.PopulateListBox(lstG36, "G36", ("Jumpgate List.JG"));
this.PopulateListBox(lstG37, "G37", ("Jumpgate List.JG"));
this.PopulateListBox(lstG38, "G38", ("Jumpgate List.JG"));
this.PopulateListBox(lstG39, "G39", ("Jumpgate List.JG"));
}
void PopulateListBox(ListBox lb, string prefix, string textfile)
{
string[] filestrings = textfile.Split(Environment.NewLine.ToCharArray());
foreach(string line in filestrings)
{
if (line.StartsWith(prefix))
lb.Items.Add(line);
}
}
Arcadian에서는 메소드의 'textfile' 인수가 파일 이름 자체가 아닌 파일로 간주됩니다. 목록 상자를 채우기 전에 파일을 문자열로 읽습니다 (예 :'string s = String.Empty; using (StreamReader sr = File.OpenText (filename)) {s = sr.ReadToEnd(); } ' – JYelton
그랬습니다. 모든 도움에 감사드립니다. – Arcadian
당신을 진심으로 환영합니다. 행운을 빕니다! – JYelton