Hi all.
I have a problem. I get all my data from a dataset (not mssql) and in that
dataset i have a table called "Activity". In this table i have a few date
fields. When i display the dataset "Activity" in a listview the date fields
is displayed like : dd.mm.yy 00:00:00. How can i format this date. I do not
want the time. Just the date.
In my dataset "activity" all date fields are formatted as: dd.mm.yyyy. Why
do i get the 00:00:00 ?? and how can i avoid it?
some code i use:
private void LoadActivityList(DataTable dtActivities)
{
//Sort the datatable
dtActivities.DefaultView.Sort = "a-stringactno";
//display datatable in listview
//Set the List to Detail View
lvActivities.View = View.Details;
lvActivities.FullRowSelect = true;
lvActivities.HideSelection = false;
lvActivities.MultiSelect = false;
//create columns to display
lvActivities.Columns.Add("Activity no.", 80,
HorizontalAlignment.Left);
lvActivities.Columns.Add("Description", 200,
HorizontalAlignment.Left);
lvActivities.Columns.Add("Status", 50, HorizontalAlignment.Left);
// BUG: this date i want to display as dd.mm.yyyy
lvActivities.Columns.Add("Created", 80, HorizontalAlignment.Left);
lvActivities.Columns.Add("Last event", 100,
HorizontalAlignment.Left);
lvActivities.Columns.Add("Contract", 0, HorizontalAlignment.Left);
lvActivities.Columns.Add("Product", 0, HorizontalAlignment.Left);
// Clear the ListView control
lvActivities.Items.Clear();
// Display items in the ListView control
for (int i = 0; i < dtActivities.Rows.Count; i++)
{
DataRow drow = dtActivities.Rows[i];
// Define the list items and get data from datatable
ListViewItem lvi = new
ListViewItem(drow["a-stringactno"].ToString());
lvi.SubItems.Add(drow["a-problem"].ToString());
lvi.SubItems.Add(drow["a-status"].ToString());
lvi.SubItems.Add(drow["a-regdate"].ToString());
lvi.SubItems.Add(drow["a-lastacteventdate"].ToString());
lvi.SubItems.Add(drow["a-contr1"].ToString());
lvi.SubItems.Add(drow["a-prodid"].ToString());
// Add the list items to the ListView
lvActivities.Items.Add(lvi);
}
this.lvActivities.Sorting = SortOrder.Ascending;
} 2 6685
Hi,
Use :
lvi.SubItems.Add(
((DateTime)drow["a-lastacteventdate"]).ToShortDateString());
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Lars Erik Nes" <La*********@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com... Hi all.
I have a problem. I get all my data from a dataset (not mssql) and in that dataset i have a table called "Activity". In this table i have a few date fields. When i display the dataset "Activity" in a listview the date fields is displayed like : dd.mm.yy 00:00:00. How can i format this date. I do not want the time. Just the date.
In my dataset "activity" all date fields are formatted as: dd.mm.yyyy. Why do i get the 00:00:00 ?? and how can i avoid it?
some code i use:
private void LoadActivityList(DataTable dtActivities) { //Sort the datatable dtActivities.DefaultView.Sort = "a-stringactno";
//display datatable in listview //Set the List to Detail View lvActivities.View = View.Details; lvActivities.FullRowSelect = true; lvActivities.HideSelection = false; lvActivities.MultiSelect = false;
//create columns to display lvActivities.Columns.Add("Activity no.", 80, HorizontalAlignment.Left); lvActivities.Columns.Add("Description", 200, HorizontalAlignment.Left); lvActivities.Columns.Add("Status", 50, HorizontalAlignment.Left); // BUG: this date i want to display as dd.mm.yyyy lvActivities.Columns.Add("Created", 80, HorizontalAlignment.Left); lvActivities.Columns.Add("Last event", 100, HorizontalAlignment.Left); lvActivities.Columns.Add("Contract", 0, HorizontalAlignment.Left); lvActivities.Columns.Add("Product", 0, HorizontalAlignment.Left);
// Clear the ListView control lvActivities.Items.Clear();
// Display items in the ListView control for (int i = 0; i < dtActivities.Rows.Count; i++) { DataRow drow = dtActivities.Rows[i];
// Define the list items and get data from datatable ListViewItem lvi = new ListViewItem(drow["a-stringactno"].ToString()); lvi.SubItems.Add(drow["a-problem"].ToString()); lvi.SubItems.Add(drow["a-status"].ToString()); lvi.SubItems.Add(drow["a-regdate"].ToString()); lvi.SubItems.Add(drow["a-lastacteventdate"].ToString()); lvi.SubItems.Add(drow["a-contr1"].ToString()); lvi.SubItems.Add(drow["a-prodid"].ToString());
// Add the list items to the ListView lvActivities.Items.Add(lvi); } this.lvActivities.Sorting = SortOrder.Ascending; }
Hi.
Thank you for your reply. I get a run-time error.
Message "the specified cast is not valid". What can be wrong. I can see that
my datatabel "dtActivities" contains a date in the field "a-lastactevetndate"
(18.06.2006 00:00:00)
Any more tips`?
Thanks.
Lars E.
"Ignacio Machin ( .NET/ C# MVP )" wrote: Hi,
Use :
lvi.SubItems.Add( ((DateTime)drow["a-lastacteventdate"]).ToShortDateString());
-- -- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Lars Erik Nes" <La*********@discussions.microsoft.com> wrote in message news:A2**********************************@microsof t.com... Hi all.
I have a problem. I get all my data from a dataset (not mssql) and in that dataset i have a table called "Activity". In this table i have a few date fields. When i display the dataset "Activity" in a listview the date fields is displayed like : dd.mm.yy 00:00:00. How can i format this date. I do not want the time. Just the date.
In my dataset "activity" all date fields are formatted as: dd.mm.yyyy. Why do i get the 00:00:00 ?? and how can i avoid it?
some code i use:
private void LoadActivityList(DataTable dtActivities) { //Sort the datatable dtActivities.DefaultView.Sort = "a-stringactno";
//display datatable in listview //Set the List to Detail View lvActivities.View = View.Details; lvActivities.FullRowSelect = true; lvActivities.HideSelection = false; lvActivities.MultiSelect = false;
//create columns to display lvActivities.Columns.Add("Activity no.", 80, HorizontalAlignment.Left); lvActivities.Columns.Add("Description", 200, HorizontalAlignment.Left); lvActivities.Columns.Add("Status", 50, HorizontalAlignment.Left); // BUG: this date i want to display as dd.mm.yyyy lvActivities.Columns.Add("Created", 80, HorizontalAlignment.Left); lvActivities.Columns.Add("Last event", 100, HorizontalAlignment.Left); lvActivities.Columns.Add("Contract", 0, HorizontalAlignment.Left); lvActivities.Columns.Add("Product", 0, HorizontalAlignment.Left);
// Clear the ListView control lvActivities.Items.Clear();
// Display items in the ListView control for (int i = 0; i < dtActivities.Rows.Count; i++) { DataRow drow = dtActivities.Rows[i];
// Define the list items and get data from datatable ListViewItem lvi = new ListViewItem(drow["a-stringactno"].ToString()); lvi.SubItems.Add(drow["a-problem"].ToString()); lvi.SubItems.Add(drow["a-status"].ToString()); lvi.SubItems.Add(drow["a-regdate"].ToString()); lvi.SubItems.Add(drow["a-lastacteventdate"].ToString()); lvi.SubItems.Add(drow["a-contr1"].ToString()); lvi.SubItems.Add(drow["a-prodid"].ToString());
// Add the list items to the ListView lvActivities.Items.Add(lvi); } this.lvActivities.Sorting = SortOrder.Ascending; } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jouke Langhout |
last post by:
Hello all!
For quite some time now, I've got the following problem:
Access won't close properly when a user closes the application. An
ACCESS process stays active and that process can only be...
|
by: Sara |
last post by:
The problem:
Conditional formatting bold, red when field Value < date() sets the
field
background to white - always - whether condition is met or not. I
want the field unfilled and just red/bold...
|
by: deko |
last post by:
I've heard it's best not to have any formatting specified for Table fields
(except perhaps Currency), and instead set the formatting in the Form or
Report. But what about Yes/No fields? When I...
|
by: hope |
last post by:
Hi,
How can I format a string field using Data Formatting Expression property in
datagrid?
For example: format last name from BROWN to Brown.
Thanks
|
by: Nalaka |
last post by:
Hi,
I have two questions about gridViews.
1. How can I intercept the row/column values at loading to change values?
2. After I update a row (using default update functionality), how can I...
|
by: johndcal |
last post by:
Hello All,
I have a date value that I pull from a .csv file.
After reading the file and storing the values in an array the value of
the date could
be found in $array, for example....
|
by: David Veeneman |
last post by:
How does one format a date column in a GridView control? I had assumed that
the DataFormat string would do it, but MSDN only shows numeric formatting
codes. Can dates be formatted using that...
|
by: Ken Wigle |
last post by:
All,
I would be very grateful for any help on this question. I have an
application in asp.net 2.0 where I dynamically create a datatable and then
bind that to a gridview. Unfortunately, the...
|
by: Tomasz J |
last post by:
Hello developers,
I bind my TextBox control specyfying a format stored in my application
global ApplicationContext object - it has a static string CurrencyFormat
property.
The problem - this...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |