0

ここでちょっと混乱しています。 にbytes変換してstring から を分割stringし、 に分割を追加してから に を追加ArrayList する配列がArrayListありListViewます。以前は機能していましたが、現在は機能していません。理由はわかりません。

//bytes to string.
string str = Encoding.Default.GetString(bytes);

// clear arraylist and listbox.
ItemDetails.Clear();
listBox1.Items.Clear();

// split the string and add the split into the arraylist.
ItemDetails.AddRange(str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));

// Add arraylist into listbox. It throws the generic error here:
listBox1.Items.AddRange(ItemDetails.ToArray());

例外の詳細:

System.Runtime.InteropServices.ExternalException was unhandled
  HResult=-2147467259
  Message=A generic error occurred in GDI+.
  Source=System.Drawing
  ErrorCode=-2147467259
  StackTrace:
       at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
       at System.Drawing.Graphics.MeasureString(String text, Font font)
       at System.Windows.Forms.ListBox.UpdateMaxItemWidth(Object item, Boolean removing)
       at System.Windows.Forms.ListBox.ObjectCollection.AddInternal(Object item)
       at System.Windows.Forms.ListBox.ObjectCollection.AddRangeInternal(ICollection items)
       at System.Windows.Forms.ListBox.ObjectCollection.AddRange(Object[] items)
       at ItemTypeEditor.FrmMain.loadItems() in c:\Users\Nicolas\Desktop\ItemTypeEditor\ItemTypeEditor\FrmMain.cs:line 254
       at ItemTypeEditor.FrmMain.FrmMain_Load(Object sender, EventArgs e) in c:\Users\Nicolas\Desktop\ItemTypeEditor\ItemTypeEditor\FrmMain.cs:line 219
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

ここにはあまり情報がないと思いますので、他に詳細が必要な場合はお知らせください。

4

1 に答える 1