The search for half-metals and spin-gapless semiconductors has attracted extensive attention in material design for spintronics. Existing progress in such a search often requires peculiar atomistic lattice configuration and also lacks active control of the resulting electronic properties. Here we reveal that a boron-nitride nanoribbon with a carbon-doped edge can be made a half-metal or a spin-gapless semiconductor in a programmable fashion. The mechanical strain serves as the on/off switches for functions of half-metal and spin-gapless semiconductor to occur. Our findings shed light on how the edge doping combined with strain engineering can affect electronic properties of two-dimensional materials