RowCount=4;
删除ValueListEditor中的第一行,如果RowCount> 1,则在delphi中
删除必须修复的行,但请:正确的代码删除行?
procedure TForm1.Button3Click(Sender: TObject);
var
DelR: Integer;
begin
if ( ValueListEditor1.Strings.Count <1 ) then Exit;
ShowMessage( ' DeleteRow № '+ IntToStr( ValueListEditor1.Row)+sLineBreak+
' ValueListEditor1.RowCount = '+ IntToStr(ValueListEditor1.RowCount)+sLineBreak+
' ValueListEditor1.Strings.Count = '+ IntToStr( ValueListEditor1.Strings.Count));
DelR:= ValueListEditor1.Row;
if ( ValueListEditor1.Strings.Count=1 ) or
( DelR=1 ) then
begin
ShowMessage(' 1 ');
if ( ValueListEditor1.Strings.Count=1 ) then
ValueListEditor1.Strings.Clear
else
ValueListEditor1.Strings.Delete(DelR);
// if ( ValueListEditor1.Strings.Count>1 ) then
// begin
// ValueListEditor1.Row:= DelR +1;
// ValueListEditor1.Strings.Delete(DelR);
// ValueListEditor1.SetFocus;
// Exit;
// end;
Exit;
end
else
if ( ValueListEditor1.Strings.Count>1 ) or
( DelR = ValueListEditor1.Strings.Count-1) then
begin
ShowMessage(' 2 ');
ValueListEditor1.Row:= DelR -1; // !!! ValueListEditor1.Row -1 = DelR
ValueListEditor1.Strings.Delete(ValueListEditor1.Row);
ValueListEditor1.SetFocus;
Exit;
end;
// else
// if ( ValueListEditor1.Strings.Count=1 )then
// ValueListEditor1.Strings.Delete(ValueListEditor1.Row)
// else
// ValueListEditor1.Row:= PreviuRow +1;
// if ( ValueListEditor1.Strings.Count>1 ) and not
// ( ValueListEditor1.Strings.Count=1 ) then
// ValueListEditor1.Row:= PreviuRow -1
// else
// if ( ValueListEditor1.Strings.Count=1 )then
// ValueListEditor1.Strings.Delete(ValueListEditor1.Row)
// else
// ValueListEditor1.Row:= PreviuRow +1;
// ValueListEditor1.Strings.Delete(ValueListEditor1.Row);
// !!!??? NOT -> ValueListEditor1.DeleteRow(ValueListEditor1.Row);
// if ValueListEditor1.Row=ValueListEditor1.RowCount then
// begin
// ValueListEditor1.DeleteRow(ValueListEditor1.Row);
// ValueListEditor1.Row:= PreviuRow;
//
// end
/// else ValueListEditor1.DeleteRow(ValueListEditor1.Row);
end;
答案 0 :(得分:2)
似乎是一个奇怪的组件..请测试以下是否符合您的要求:
if ValueListEditor1.Row - Ord(doColumnTitles in ValueListEditor1.DisplayOptions)
< ValueListEditor1.Strings.Count then begin
if (ValueListEditor1.Row = 0) then
ValueListEditor1.Strings.Delete(0)
else
ValueListEditor1.DeleteRow(ValueListEditor1.Row);
end;