Rational manipulation of lattice strain to tailor the electronic and optical properties of nanostructures