Ваш цикл выполняется по всем строкам, пропуская только первую строку.
Хотя я не вижу, что происходит в вызове FileClose, похоже, что в этом нет никакого смысла, поскольку ReadAllLines уже закрыл файл.
Вы можете получить вторую строку вашего файла с одной строкой кода
Dim line as String = File.ReadLines(OrderID & ".txt").Skip(1).Take(1).FirstOrDefault()
' this check is required to avoid problems with files containing 0 or 1 line
if line IsNot Nothing Then
Dim cells = line.Split(","c)
dgvOutput.Rows.Add(cells)
End If
Обратите внимание, что я заменил ReadAllLines на ReadLines. Это лучше, потому что, используя этот метод, вы не читаете все строки, когда вам нужна только вторая (если она существует). Больше информации на ReadLines vs ReadAllLines
Самый простой путь состоит в том, чтобы, вероятно, разделить на подклассы NSTextFieldCell
и переопределение -drawInteriorWithFrame:inView:
и -selectWithFrame:inView:editor:delegate:start:length:
.
Необходимо будет решить сколько пространства, чтобы выделить для количества и потянуть в сокращенном пространстве. Что-то вроде этого пример кода должен работать, хотя это не было протестировано в округленном текстовом поле.
Можно найти больше информации о разделении на подклассы NSCell
в примере кода PhotoSearch Apple.
- (void)drawInteriorWithFrame:(NSRect)bounds inView:(NSView *)controlView {
NSRect titleRect = [self titleRectForBounds:bounds];
NSRect countRect = [self countAreaRectForBounds:bounds];
titleRect = NSInsetRect(titleRect, 2, 0);
NSAttributedString *title = [self attributedStringValue];
NSAttributedString *count = [self countAttributedString];
if (title)
[title drawInRect:titleRect];
[count drawInRect:countRect];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength {
NSRect selectFrame = aRect;
NSRect countRect = [self countAreaRectForBounds:aRect];
selectFrame.size.width -= countRect.size.width + PADDING_AROUND_COUNT;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(__textChanged:) name:NSTextDidChangeNotification object:textObj];
[super selectWithFrame:selectFrame inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
- (void)endEditing:(NSText *)editor {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:editor];
[super endEditing:editor];
}
- (void)__textChanged:(NSNotification *)notif {
[[self controlView] setNeedsDisplay:YES];
}