.NET DataViewGrid отображает дату и время в столбце, если только не полночь, тогда вы видите только датуC#

Место общения программистов C#
Anonymous
.NET DataViewGrid отображает дату и время в столбце, если только не полночь, тогда вы видите только дату

Сообщение Anonymous »

Я показываю дату и время в столбце DataViewGrid, и это работает так, как ожидалось, если только не полночь, а тогда отображается только дата. Я хочу, чтобы время отображалось несмотря ни на что.

Изображение

// Stores the SQL query to populate the appointments DataGridView.
string str_sql = "select title as Title, start as Start, end as End, " +
"customer.customerName as Customer, " +
"user.userName as Consultant, appointmentId as ID " +
"from appointment as appt " +
"left join customer on customer.customerId = appt.customerId " +
"left join user on user.userId = appt.userId " +
"order by start;";

// Associates the SQL command with the active MySQL connection.
MySqlCommand cmd = new MySqlCommand(str_sql, mysql.Conn);

// Creates a data table to store the results of the SQL query.
DataTable dt_appointments = new("Appointments");

// Fills the data tablewiththe output from the query.
dt_appointments.Load(cmd.ExecuteReader());

// Loops through each row in the appointments data table.
foreach (DataRow dr in dt_appointments.Rows)
{
// Adjusts the appointment start and end times from UTC to the user's local time.
dr["Start"] = dr["Start"].As().ToLocalTime();
dr["End"] = dr["End"].As().ToLocalTime();
}

// Tells the DataGridView that its data source is the data table (sql query results).
dgv_appointments.DataSource = dt_appointments;

Вернуться в «C#»