Knowledge Base



KB10377 - How to edit attribute by selecting existing values from a database.

There is no direct way to do this. If you are using SQL database, you can query for DISTINCT field values. If you are using a file based layer, you can use a string list which has the distinct values.

 lst_name := TStringList.Create ;
 lst_name.Duplicates := dupIgnore ;
 lst_name.CaseSensitive := False ;

 // do this only once
 ll.MoveFirst( GisWholeWorld, '' )
 while not ll.Eof do begin
  try
   lst_name.Add( ll.Shape.GetField( 'NAME' ) ) ;
  except
   // nothing - just duplicated value
  end ;
   ll.MoveNext ;
 end ;

 // and this on each attribute change
   my_shape.SetField( 'NAME', some_value ) ;
   try
   lst_name.Add( my_shape.GetField( 'NAME' ) ) ;
  except
   // nothing - just duplicated value
 end ;
Created: November 21, 2003, Modified: January 22, 2013
follow us on Facebook  follow us on Twitter  follow us on Google +  follow us on LinkedIn  Embarcadero