  We present a study of the $X(3872)$ lineshape in the decay $B \to X(3872)K\to
D^0\overline{D}{}^{*0}K$ using a data sample of $772\times 10^6$
$B\overline{B}$ pairs collected at the $\Upsilon(4S)$ resonance with the Belle
detector at the KEKB asymmetric-energy $e^+e^-$ collider. The peak near the
threshold in the $D^0\overline{D}{}^{*0}$ invariant mass spectrum is fitted
using a relativistic Breit-Wigner lineshape. We determine the mass and width
parameters to be $m = 3873.71 ^{+0.56}_{-0.50} ({\rm stat}) \pm0.13 ({\rm
syst}) ~{\rm MeV}/c^2$ and $\Gamma_0 = 5.2 ^{+2.2}_{-1.5} ({\rm stat}) \pm 0.4
({\rm syst})~{\rm MeV}$, respectively. The branching fraction is found to be
${\cal B} (B^+\to X(3872)K^+) \times {\cal{B}}(X(3872) \to
D^0\overline{D}{}^{*0}) = (0.97 ^{+0.21}_{-0.18} ({\rm stat}) \pm 0.10 ({\rm
syst})) \times 10^{-4}$. The signal from $B^0$ decays is observed for the first
time with $5.2\sigma$ significance, and the ratio of branching fractions
between charged and neutral $B$ decays is measured to be ${\cal B}(B^0\to
X(3872)K^0)/{\cal B}(B^+ \to X(3872)K^+) = 1.34^{+0.47}_{-0.40} ({\rm stat})
^{+0.10}_{-0.12} ({\rm syst})$. The peak is also studied using a Flatt\'{e}
lineshape. We determine the lower limit on the $D\overline{D}{}^{*}$ coupling
constant $g$ to be $0.075$ at 95% credibility in the parameter region where the
ratio of $g$ to the mass difference from the $D^0\overline{D}{}^{*0}$ threshold
is equal to $-15.11~{\rm GeV}^{-1}$, as measured by LHCb.
