[Lazarus] [Fwd: Re: DisplayFormat property of dbgrid?]

Howard Lee Harkness howard.lee.harkness at gmail.com
Sat Jul 19 23:54:45 CEST 2008


On Sat, Jul 19, 2008 at 8:22 AM, Ivan Gan <ivan at comchatter.com> wrote:

> Hi Howard,
>
> you said:
>> "I wasn't able to tell that the DisplayFormat property of dbgrid did
>> anything at all. Is this documented anywhere?
>>
>> And apparently, there is no EditFormat property at all. What I want to
>> do is some rudimentary validation, e.g., make sure a zipcode is exacty
>> five characters long and all characters are digits. How do I do that in
>> a Lazarus/FPC dbgrid?"
>>
>
> you could use a try...except block to attempt to convert the number to
> an integer, this would tell if it is wrong, length could be achieved
> with length(inputstring) , it should also work with UTF-8 as numbers are
> a single byte subset of the UTF-8 encoding system, I wouldnt like to try
> it for text length on non latin text though
> Why limit yourself to zip codes though, an application should have a
> more international appeal
> A british postcode is like this B1 24NJ, CV21 3HB
> If your using Zeos database components, specifically the table
> component, the field events onGetText & OnSetText could be a good place
> to do your checking


I wanted to keep this as simple as possible, so I'm only considering
US-style zipcodes. This is for an attorney's client contact database, so it
will only have current Texas residents.

I'm not using the Zeos components, although I've seen them recommended here.
I've got the zipcode maintenance screen working -- maybe even good enough --
with about 8 lines of my own code, using PostgreSQL and sqldb components.
The UI is a bit funky (for instance, clicking on 'edit' in the dbNavigator
doesn't cause the field in the dbGrid to get the focus), and I would like to
fix some of the aggravation, but it does allow me to do everything that has
to be done.

>
>
> By having a mask field in the country table it should be possible to set
> the country first then match the postcode, this is the approach I am taking
> I have extensive lists in MySql on ZIP codes, countries, province/state,
> cities etc. which I have no objection to sharing

Well, as I thought I had mentioned, there does not appear to be any masking
available in the dbGrid component. I suppose I need to look at Zeos,
assuming Zeos will work with PostgreSQL.

>
> I am also working on an address book project
> Basically it is being designed with Lazarus 0.9.25 beta for the UTF-8
> support
> Database is MySql using Zeos database components
> The address lists are being built to show address information in dual
> language format, so China shows in English & Chinese, Israel in English
> & Hebrew
> The real kicker though is in connecting it over the net to exchange
> non-personal address data with a central server
> So if you enter the Hebrew translation for Tel-Aviv it will become
> available to all other users worldwide
> I already have Chinese provinces in Chinese!
> Thanks to US policy I have fairly complete lists on US postcodes &
> Cities but limited for other countries at the moment
>
Sounds like your project is substantially more ambitious than mine.
-- 
Howard Lee Harkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080719/504c17f5/attachment-0007.html>


More information about the Lazarus mailing list