This is a migrated thread and some comments may be shown as answers.

Date Format in DetailView

12 Answers 462 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 04 Dec 2012, 11:46 AM
Hi,

I need help with one problem. I got databound ListView on windows form.
One of the columns in bound data is of DateTime type.
How do I display it in format dd/MM/yyyy (without time).
I can return date from database as already formated string but then sorting on this column
works on string value not DateTime.
I can't find way around it. Any help would be greatly appreciated.

Thanks
Chris

12 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 06 Dec 2012, 05:17 PM
Hi Chris,

Thank you for contacting us.

You can handle the CellFormatting event to apply any custom formatting over the cells in DetailView. The following sample demonstrates this:
void radListView1_CellFormatting(object sender, Telerik.WinControls.UI.ListViewCellFormattingEventArgs e)
{
    if (e.CellElement.Data == this.radListView1.Columns["OrderDate"] && e.CellElement is DetailListViewDataCellElement)
    {
        e.CellElement.Text = String.Format("{0:dd/MM/yyyy}", ((DetailListViewDataCellElement)e.CellElement).Row[e.CellElement.Data]);
    }
}

The above code will modify only the visual representation of the cells and sorting and filtering operations will work as expected with the underlying value.

I hope you find this useful. Feel free to write back if you have any additional questions.

All the best,
Ivan Todorov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Balamurugan
Top achievements
Rank 1
answered on 27 Sep 2013, 07:31 AM
how to work with Price Format in RadListview. i use to modify ur Date Format code like shown below.. But, CellFormatting not at all firing when debugging... 

if (e.CellElement.Data == this.radListView1.Columns["Price"] && e.CellElement is DetailListViewDataCellElement)
            {
                FontStyle fstyle = FontStyle.Regular;
                e.CellElement.Font = new Font(ff, 20, fstyle);
                e.CellElement.Text = String.Format("{0:`0.00##}", ((DetailListViewDataCellElement)e.CellElement).Row[e.CellElement.Data]);
            }
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Oct 2013, 03:29 PM
Hello,

Thank you for contacting Telerik Support.

In order to achieve price formatting, please, have a look at the following code snippet:
public partial class Form1 : Form
{
    Font font = new Font("Arial", 12f, FontStyle.Regular);
 
    public Form1()
    {
        InitializeComponent();
 
        this.radListView1.CellFormatting += radListView1_CellFormatting;
    }
 
    private void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
    {
        if (e.CellElement.Data == this.radListView1.Columns["UnitPrice"] && e.CellElement is DetailListViewDataCellElement)
        {
            e.CellElement.Font = font;
            e.CellElement.Text = string.Format("{0:C}", ((DetailListViewDataCellElement)e.CellElement).Row[e.CellElement.Data]);
        }
    }
 
    private void Form1_Load_1(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'nwindDataSet1.Order_Details' table. You can move, or remove it, as needed.
        this.order_DetailsTableAdapter1.Fill(this.nwindDataSet1.Order_Details);
    }
}

Note that font creating is a time consuming operation, that is why it is better to be created in advance.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Balamurugan
Top achievements
Rank 1
answered on 03 Oct 2013, 04:33 AM
The Source Code which u Posted to achieve  Price Formatting, was fine and good.. Its Working.. Thanks.. 

Could u Please do me one more favor, I am trying to Fetch Price Amount based on Product ID.

Ex: Kindly Take look on "DetailsView.png" 

Requirements:

Input(textbox_KeyPress):- OrderID-10248

Output(textbox OR label):- UnitPrice-14.00

How can i achieve this task in RadListView.
  
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Oct 2013, 03:27 PM
Hello,

Thank you for writing back.

Please, find the attached sample project, demonstrating the functionality from the attached picture.

I hope this information helps. Should you have further questions, I would be glad to help.


Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Balamurugan
Top achievements
Rank 1
answered on 09 Oct 2013, 10:38 AM
Excellent work buddy.. The Sample code which u posted is really good.. and its working fine.. 

Thanks buddy..

I have TWO More Doubts..

1. If we use Telerik controls in windows form application.. Usually the form takes time to load or is there any other Problem.
i am using RadListView in one of my form. Particularly, the "Form" where i used RaddListView is taking more time to load. also              the input which i use to  give in commandbarTextBox.


2. How to use WPF in WinForms.. Need any Sample
0
Balamurugan
Top achievements
Rank 1
answered on 09 Oct 2013, 10:46 AM

Pls Find the Attached..

1. Using RadListView in one of my Form.. Particularly, the "Form " where i am using RadListView, it takes more time to load. Could u pls tell me why? Or is it is normal if we use telerik controls? 

2.How to use WPF in WinForms. Need Sample Project.

0
Balamurugan
Top achievements
Rank 1
answered on 10 Oct 2013, 07:25 AM


Grid1: Grid2:

s.no name PH#                                                       s.no name PH#
                                                                                                  |-->            2  john 565
          1  bala 123                                                    |
   2  john 565   ---->(Cell_ClickEvent(RowSelect))


both the Grids are in same "Form"
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Oct 2013, 02:23 PM
Hello,

Thank you for writing back.

In contrast to the standard MS WinForms controls which are just wrappers of the native Win32 controls, our controls support theming, animations and some other extended features. This slightly reflects on performance. Nevertheless, we constantly try to improve controls' performance and to optimize them. We also take serious all performance issues reported from our customers and try to solve them with high priority. Please take a look at this KB article, it gives some basic ideas on how to improve the performance of RadControls for WinForms.

In general, we do not have any special means to host a Telerik WPF controls in a WinForms project and if the ElementHost is not appropriate for your scenario I am afraid that I cannot give you any other way to do that. Nevertheless, you can get some general information and samples related to the topic in the MSDN library - WPF and Windows Forms Interoperation.

As to the question from your last post, the provided information is not sufficient to understand what is the exact requirement. Please give us more details.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Balamurugan
Top achievements
Rank 1
answered on 15 Oct 2013, 12:13 PM


How to Add Multiple Records from Grid1 to Grid2 on cell_click event.. 
0
Balamurugan
Top achievements
Rank 1
answered on 16 Oct 2013, 10:52 AM

Please Take a look on Attached Below,

Why did it Happens? When i use to transfer data from one Grid to another grid, the existing grid data got invisible..

Kindly Post As soon as possible..

Thanks for ur Services..
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Oct 2013, 06:28 AM
Hello,

Your latest question seems to concern RadGridView while the initial topic of this forum thread is related to RadListView. That is why I would like to kindly ask you to open a new thread concerning your RadGridView questions and to avoid mixing different subject in the same thread in future. This way we will allow the community to find the necessary answers easily.

You can also have a look at our forum guidelines here: http://www.telerik.com/community/forums/winforms/listview/important-information-on-using-the-telerik-forums.aspx.

Thank you for your understanding.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListView
Asked by
Chris
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Balamurugan
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or