Maxsize in a DBGrid + ZEOS + Firebird [SOLVED] lazarus / 16-Databases ---------------------------------------------------------------------- Mando · 2011-02-17 12:44 HELLO ALL!!! My problem is How can i set the Size for a DBGrid column wich field is ftString type. I want to limit the user input to the size of field. Whe I write a string larger than then field size, I get an exception: SQL Error: Arithmetic exception, numeric overflow, or string truncation. ErrorCode: -802 I Know I can intercept the exception, but visually, an user can type larger strings than the field size. Please Help me!!!! thx ---------------------------------------------------------------------- Mando · 2011-02-21 15:35 Hi, nobody know the answer? please, help me!!!!!! ---------------------------------------------------------------------- fredycc · 2011-02-21 16:23 Mmm I don't remember very well by if you use a ZQuery you can define the defaul size of any field and check it before try execute any query to avoid that problem, another way is usgin DBGridKeyPress Event, whit his you can evaluate any key that use press and check the size and lauch a message. Regards. ---------------------------------------------------------------------- Mando · 2011-02-21 16:47 thx for your answer, but i want do it automatically, limit the user input at edit time, not after, because can lose data. with DBEdit, I can set maxlength property to limit the length of the input. regards. ---------------------------------------------------------------------- Mando · 2011-02-21 17:57 SOLUCIONADO / SOLVED The solution I find: in selectEditor evejnt of the DbGrid I put this: Code: [Select]  if column.fied.DataType=ftString then TEdit(Editor).MaxLength:=column.Field.Size div 4; and  now, and other question. I must divide Field.Size by 4 to get the actual width of the string fields. It could be because my database is UTF8? reagards. ---------------------------------------------------------------------- Lacak2 · 2011-02-22 05:23 There is already bugreport regarding to MaxLength http://bugs.freepascal.org/view.php?id=18562 And yes, ATM you must divide Size by "character width", but IMO this is not good, because Size should be "character length" ...