Я отображаю дату и время в столбце DataViewGrid, и это работает так же, как и ожидалось, если это не полуночи, а затем она отображает только дату. Я хочу, чтобы это отображало время, независимо от того, что.
< /p>
< /p>
< /p>
// 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;< /code>
< /div>
< /div>
< /p>
Спасибо за вашу помощь,
Christian < /p>
Подробнее здесь: https://stackoverflow.com/questions/797 ... midnight-t
.Net DataViewGrid отображает как дату, так и время в столбце, если не на полуночи, тогда вы видите только дату ⇐ C#
Место общения программистов C#
1752545026
Anonymous
Я отображаю дату и время в столбце DataViewGrid, и это работает так же, как и ожидалось, если это не полуночи, а затем она отображает только дату. Я хочу, чтобы это отображало время, независимо от того, что.
< /p>
< /p>
< /p>
// 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;< /code>
< /div>
< /div>
< /p>
Спасибо за вашу помощь,
Christian < /p>
Подробнее здесь: [url]https://stackoverflow.com/questions/79701400/net-dataviewgrid-displays-both-date-and-time-in-a-column-unless-its-midnight-t[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия