Displaying NewPing distance data on LiquidCrystal_I2C

When I run this program the distance value is displayed only in the first column.
Running the same program on the same type display without the I2C works correctly.
Can you help me correct this?
Thank you in advance.
Ed

// LCD_I2C-text-distance

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <NewPing.h>
#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);


void setup() {
  lcd.begin(16,2);
  lcd.init();
  lcd.backlight();
  lcd.print("Distance cm");
}

void loop() {
  delay(50);
  unsigned int uS = sonar.ping_cm();
  unsigned int D = uS/US_ROUNDTRIP_CM;
  lcd.setCursor(0,1);
  lcd.print(D);
}

You need to update the version of the LiquidCrystal_I2C.h library you are using. There was a bug fixed long ago.

https://forum.arduino.cc/index.php?topic=365435.0

Better yet would be to convert to the hd44780 library as recommended. Download from the library manager.

See LCD troubleshooting