The family were living in Nemphlar on census day 1881 - William L Main, 54, land measurer DC; wife Mary, 49; Margaret, 21; Robert, 18; Mary, 14; Jessie, 12; Susan, 6; and William A L Main, grandson, 1. Mary sr born Campsie, Stirlingshire, all the rest born in (parish of) Lanark, Lanarkshire. However there is no address on the LDS transcription of the census. It is possible that there might be more on the original, available at modest cost at Scotland's People. The census indexes for 1891 and 1901 still list them in (the parish of) Lanark, so either of those may have a fuller address for where they were living.
So any connection to Lockhart must be before 1826/27 when William Lockhart Main was born. The first step is to find out who his parents were. Have you got a copy of his death certificate?
If not, you can get it from
www.scotlandspeople.gov.uk at modest cost. William Lockhart Main died in (the parish of) Lanark in 1903, aged 78, and Mary Bryce or Main died in the same parish in 1901, aged 70. Their death certificates will tell you the addresses where they died, and (assuming the informant knew this) the full names of both sets of parents, including their mothers' maiden name. Then you can set about looking for a baptism record.
Edit: this post crossed with that of anne_p above.