比如~~procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
  if DBGrid1.SelectedField.DataType = ftString then
  label1.Caption := 'String';
  if DBGrid1.SelectedField.DataType = ftInteger then
  label1.Caption := 'Integer';
end;

解决方案 »

  1.   

    lable1.Text:=ADOTable1.Fields[i].DataType
      

  2.   

    楼上兄弟知不知道DataType不是String类型的??
    Label1没有Text~~
    还有人知道更好的方法吗??请指教!!
      

  3.   

    var
      i:integer;
      s:string;
    begin
      for i:=0 to tbl.FieldCount-1 do
      begin
        //memo1.lines.Add(tbl.Fields[i].ClassName);
        case tbl.Fields[i].DataType of
          ftUnknown: s:='ftUnknown';
          ftString:s :='ftString';
        end;
         memo1.lines.Add(s);
        { ftSmallint, ftInteger, ftWord,
        ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,
        ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo,
        ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar, ftWideString,
        ftLargeint, ftADT, ftArray, ftReference, ftDataSet, ftOraBlob, ftOraClob,
        ftVariant, ftInterface, ftIDispatch, ftGuid
        //以此类推
         }
      end;
    end;
      

  4.   

    作一个字符数组
    const 
      SLabel_Datatype: array [TFieldType] of string = 
      ('ftSmallint', 'ftInteger', ...);//对应TFieldTypeS := SLabel_DataType[Field[I].DataType];
    memo1.Lines.Add(S);