大 大大懒虫 Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-29 #1 dbgrid 中如果关联的表有多条记录,但我只需要其中的几条,并因条件不同显示不同, 并且列数也不同。所以我要在程序中动态生成。我请问各位大虾如何建立一个columns
H hj5000 Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-29 #2 你可以把columns的visibale设成false,要的时侯再设为true 。
Z zm30 Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-29 #3 var col:TColumn; begin col:=DBGrid1.Columns.Add; col.fieldname:='field1'; end;
E Expert Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-29 #4 DBGrid1.Columns.Add; DBGrid1.Columns[DBGrid1.Columns.Count-1].FieldName:='YourFieldName'; DBGrid1.Columns[DBGrid1.Columns.Count-1].Title.Caption:='YourNewTitle';
DBGrid1.Columns.Add; DBGrid1.Columns[DBGrid1.Columns.Count-1].FieldName:='YourFieldName'; DBGrid1.Columns[DBGrid1.Columns.Count-1].Title.Caption:='YourNewTitle';
H halps Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-30 #5 用Add添加要显示的列,用delete删除不要的列就行了。
C coldew Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-30 #6 hj5000的方法是我经常用的。 挺有效的你也不防一用。
M mlzhou Unregistered / Unconfirmed GUEST, unregistred user! 2002-05-30 #8 Table2.TableName:=aaaa; Table2.Active:=true; DBGrid1.Columns.Clear; DBGrid1.Columns.Add.FieldName:='aa1'; DBGrid1.Columns.Items[0].Title.Caption:='编 号'; DBGrid1.Columns.Items[0].Title.Alignment:=taCenter; DBGrid1.Columns.Items[0].ReadOnly:=false; DBGrid1.Columns.Add.FieldName:='aa2'; DBGrid1.Columns.Items[1].Title.Caption:='姓 名'; DBGrid1.Columns.Items[1].Title.Alignment:=taCenter; DBGrid1.Columns.Items[1].ReadOnly:=false;
Table2.TableName:=aaaa; Table2.Active:=true; DBGrid1.Columns.Clear; DBGrid1.Columns.Add.FieldName:='aa1'; DBGrid1.Columns.Items[0].Title.Caption:='编 号'; DBGrid1.Columns.Items[0].Title.Alignment:=taCenter; DBGrid1.Columns.Items[0].ReadOnly:=false; DBGrid1.Columns.Add.FieldName:='aa2'; DBGrid1.Columns.Items[1].Title.Caption:='姓 名'; DBGrid1.Columns.Items[1].Title.Alignment:=taCenter; DBGrid1.Columns.Items[1].ReadOnly:=false;