How to format listbox items with dashes (no binding)?

Hi all,
I have a couple of listboxes that I fill with data just by assigning the lists (List<Int32> or List<String>) to  myListbox.ItemsSource. I think I need to convert Int32 to string first, then add dashes. The string list I can just add the
dashes. I also need to get the original value (either Int32 or String) when I select an item in any listboxes from the selectionChanged event.
I read about value converters but I'm not sure how to use them without data binding.
Can someone point me in the right direction please?
Thanks
//---- List<Int32>
List<Int32> woList = new List<Int32>();
//assume woList=1234567, 3456789. I need to display it as 12345-67, 34567-89
workOrderListbox.ItemsSource = woList;
//---- List<String>
List<String> pnList = new List<String>();
//assume pnList=123456789AXC, SDF3456789FR. I need to display it as 12-3456789-AXC, SD-F345678-9FR
partNumberListbox.ItemsSource = pnList;

You could just define an ItemTemplate for the ListBox and then use a converter as usual:
namespace WpfApplication61
public class YourConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
//123456789AXC
string s = value as string; //or string s = System.Convert.ToInt32(value).ToString();
if (s.Length < 12)
return s;
return string.Format("{0}-{1}-{2}", s.Substring(0,2), s.Substring(2,7), s.Substring(9));
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
<ListBox Name="partNumberListbox" xmlns:local="clr-namespace:WpfApplication61">
<ListBox.Resources>
<local:YourConverter x:Key="conv"/>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=., Converter={StaticResource conv}}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public Window2()
InitializeComponent();
List<String> pnList = new List<String>();
pnList.Add("123456789AXC");
partNumberListbox.ItemsSource = pnList;
The UI element in the visual ListBoxItem container (TextBlock) that gets created will always binds to some source property of the object in the ItemsSource.
You can not apply a StringFormat on a string value and also using a converter is a more flexible way to customize the display of a source property.
Hope that helps.
Please remember to close your threads by marking helpful posts as answer and then please start a new thread if you have a new question.

Similar Messages

  • How to add Excise item with out chapter id

    Dear all,
    How to add Excise item with out chapter id?
    Chapter id of purchae items will be known only after receiving Invoice/gate pass/delivery  chalan from supplier/vendor
    To send a purchase order we need to create that particular item in the master, but with out assigning chapter id system is  not allowing to save without chapter id.
    How to solve this?
    I am with SAP 8.8 and PL 10
    Thanks in advance
    regards,
    Kumar

    Hi Kumar,
    Refer the book of chapter ID or find out on internet you will get the chapter ID.
    Still if you not able to get  the chapter id then consult with excise advisory.
    But you can add Excise PO until you have the excise details in Item master.
    Regards,
    Datta Kharat

  • How to format a form with adf

    Hi,
    I want to format an adf form like this :
    http://dl.dropbox.com/u/33421977/adf_form.PNG
    To do this I have used af:panelDashboard and af:panelBox with af:panelFormLayout inside.
    Now I don't want to use panelBox anymore, but I don't know how to achieve this without panelDashboard/panelBox.
    What is th best aproach to do this? Can you send me some links which explain how to format a form with adf?
    Thanks.

    Is just a question of style. In the real application this form is included in another panelBox. So it looks too... I don't know how to say it... too heavy?
    In fact I don't want to see these panelBoxe's borders. Maybe I have just to change the style of these boxes? Do you know if it is possible?
    But more generally, what is the right way to format adf forms? Can I achieve this sort of formatting just using panelFormLayout?

  • How to show catalog items with Approval Status:Pending in a Content Search Webpart

    How to show catalog items with Approval Status:Pending in a Content Search Webpart using cross site publishing. Thanks in advance.

    I don't think you're going to be able to. Usually Approval Status is used in conjunction with Major/Minor versioning and while Approval Status is pending the item is usually a draft.
    As a result the search crawler should not be able to see the draft items as it would not have the necessary rights to do so. (Good practice ensures that the Search Crawler has only read access and is not an elevated account for this reason)
    Paul.
    Please ensure that you mark a question as Answered once you receive a satisfactory response. This helps people in future when searching and helps prevent the same questions being asked multiple times.

  • Need detailed procedure on how to add an item with Item Style Check Box in

    Need detailed procedure on how to add an item with Item Style Check Box in Framework.

    The view instance should be the same as the view instance (view object) specified for your region.
    If the View Attribute already that you need already exists in the View Object then you can use it.
    Otherwise you have to extend the View Object and add the new attribute to it.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to create list items with multiple attachment files using rest api javascript

    In one of user form I am using javascript rest api to create a list item with multiple attachment files. So far I am able to create list item and once created uploading an attachment file. But this is two step process first create an item and then upload
    a file.
    It create an additional version of the item which is not desired. Also I am not able find a way to attach multiple files in a go. Following is the code I am using.
    createitem.executeAsync({
                    url: "/_api/web/lists/GetByTitle('UserForm')/items(1)/AttachmentFiles/add(FileName='" + aFile.name + "')",
                    method: "POST",
                    contentType: "application/json;odata=verbose",
                    headers: {
                        "Accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    binaryStringRequestBody: true,
                    body: fileContent,
                    success: fnsuccess,
                    error: fnerror
    So somehow I need to combine item attributes along with attachment files in body: param. I visited https://msdn.microsoft.com/en-us/library/office/dn531433.aspx#bk_ListItem but no success.
    Appreciate any help.

    Thanks Mahesh for the reply and post you share it was useful.
    But this does not solve the core of the issue. You are uploading attachments after creation of item and multiple files are being attached in loop. This is kind of iterative update to an existing item with attachments. This will end up creating multiple versions. 
    What I am trying to achieve is to create an item along with multiple attachments in a go. No item updates further to attach a file.
    Please suggest how this can be done in one go. SharePoint does it when one creates an item with multiple attachment.
    Thanks for your reply.

  • How to format Windows drive with Mac OS format

    Hello
    I have a Windows 160gb internal drive that is formated in Fat32. I am unable to format this drive with Mac OS X 10.3.9 in order to install Tiger 10.4. When I attempt to format using the Mac OS extended (journaled), I receive an error (sorry I didn't write it down) partition error. If I use the Mac OS extended option I recieve an error that the drive can not be unmounted.
    How can I format this 160gb drive with Mac OS format so that I may install Mac OS X 10.4
    Thank you

    Do the following:
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder. If you need to reformat your startup volume, then you must boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger or Leopard.)
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process will take 30 minutes to an hour or more depending upon the drive size.
    Steps 4-6 are optional but should be used on a drive that has never been formatted before, if the format type is not Mac OS Extended, if the partition scheme has been changed, or if a different operating system (not OS X) has been installed on the drive.

  • How to create an item with date type mm/yyyy (no day)

    Hello,
    Is it possible to create an item with date type mm/yyyy (no day)? I want the pop-up date picker to just show month and year.
    Thanks,
    Jen

    Hi,
    you cannot pop-up date picker to just show month and year, but you can set your item format as MM-YYYY
    You can check this APEX_ITEM.DATE_POPUP2 at : http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_item.htm#CHDJHBCG (if using apex 4.1) else http://docs.oracle.com/cd/E10513_01/doc/apirefs.310/e12855/apex_item.htm#CHDFDDEI
    Edited by: Sergio_doudou on 2012-04-13 14:26

  • PLEASE HELP: How to format ext HD with Disk Utilities (FAT32 format)

    Hi,
    Please help. I need to format a 360 GB Lacie Hard-drive on FAT32 format. How can I do it with the Disk Utilities Application? I tried but only see Apple extended, extended (journaled), MS-dos, and others, but no FAT32. Also, if the Hard drive has 20 GB of documents, can a format the resto of the drive and leave this info intact? If so how can I do it. Thanks so much. I appreciate your help.
    MacBook Pro   Mac OS X (10.4.3)  

    You have to backup any data on the hard drive first.
    Formatting erases anything on the partition which in your case is the entire hard drive. It is possible to create more than one partition on the hard drive but that process will also delete any data on the hard drive.

  • Email : How to format text item such as (subjectline ,body text)

    Hi
    what i mean to say is, when we send mail through OLE2 using d2k via lotus notes. How can i format text item such as (subjectline ,body text) etc.
    Thanks in advance
    Vishal

    I'm not sure, what you want?
    I for myself create 2 items and the subject-item is used for the subject-parameter and the body-item for the body

  • How to restore cancelled Item with DI API

    Hello,
    how can I restore a cancelled Item with DI API ?
    Regards,
    Jan

    Hi Jan,
    Obviuosly there's no method in DI API's Items object available for that - i.e. you would need to go through the SAP Business One application to handle that (eventually through UI API-based workarounds...).
    Sorry,
    Frank

  • Selecting listbox item with right mouse click

    Hi,
    I have a listbox control with non editable items.  Is there an easy way to select an item with a right mousebutton click (Like the left click)
    Solved!
    Go to Solution.

    Create an Event structure and generate an event on the Mouse Down? event.  Then use the Button terminal to determine if the right button was pressed.  If it was then set the value of that listbox to the row that the mouse is over.  You can do this using the invoke node Point to Row.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How to create web items with different quantities?

    Hi,
    I have B1 inventory items that are single items but we will be selling them on the web as 'packages' of different quantities.  For example, we would like the user to be able to select the web item, then be presented with a drop down (attribute) of case (10 items), 1/2 pallet (80 items) or full pallet (160 items).  Is it possible to setup a product line master which is a B1 inventory item, then define the child items, non B1 items, and somehow have the proper quantities ordered?  (ie. ordering 2 cases creates a B1 order for our parent item with a quantity of 20)
    If I can do this, I have another concern.  Since we are currently using our test database, if I setup all of these child items and create the parent/child relationships, will these be lost once we swtich the database over to our live/production database?
    Thanks,
    David

    Personally, I would add the javascript to the Item's description with additional drop downs there, upon selecting the drop down, this would populate the QTY field which i would hide via javascript as well, but will be passed on to the Cart/checkout page.
    There is a somewhat similar discussion here:
    [Re: Custom price logic|Re: Custom price logic]
    James

  • How to clear line items with withholding tax manually

    hi Experts,
    i posted a vendor invoice with withholding tax and i made payment as well but not through f-58.
    now i wanted to clear these two through f-44 but it gives the message withholding tax information ignored and didnt display the invoice as open item.
    how do i clear both the trasactions
    regards
    suresh

    hi Praisty,
    thanks for the reply
    i have a second opinion on your statement that no matter whatever tcode you use for payment it will clear the open item. Even in F-58, if u make partial payment it will not clear you open item. But i didnt use f-58 as i said earlier.
    i used FBV1 for parking the document through which i entered the payment details...ofcourse it doesnt have the option for clearing the open items, cheque printing and it will not update your cheque register. i posted the parked document through FBV0. for all practical purposes, this is my payment document but it didnt clear my open item, in order to clear it i now used f-44.
    regards
    suresh

  • How to format the report with the aggregated value

    Hi,
    I have 2 characteristics and 3 KFs in the infocube.
    First field is Cost Center
    Second field is creation Date
    3rd field is KF1
    4th field is KF2
    5th field is KF3
    I have put the date field( in the row) as this is required for calculating formula for KFs. But I have set that as No display.
    The date in the info cube is as follows.
    Cost Ceneter  Date( no Display)   KF1     KF2      KF3
    CC1           01/01/2006          100     150      200
    CC1           02/02/2006          75      100      95
    CC1           05/02/2006          125      95      125
    CC2           01/02/2006          75       25      85
    CC2           02/02/2006          85       65      10
    As the Date field is in query set to No display so the date appearing in the report is as follows
    CC1       100        150        200
              75         100        95
              125          95        125
    CC2       75           25        85
              85           65        10
    But I want the aggregated value at cost senter level i.e.
    CC1       300         245       420
    CC2       160         90         95
    I can not remove the Date frield from query as there is a formula variable defined on the date field.
    Please let me know how to bring the report to the required format.
    Bill
    Message was edited by:
            Bill Bryan

    If you are in new Bex, you can do it.
    You will have to create another (set of) CKF on top of the current ones (which do exception aggregation on DOCNUM) and set the exception aggregation on date.
    Say you have
    CH1--CH2CH3--CKF1
    To have a 'before aggregation' behavior for CKF1 when CH3 is not present, you will create a CKF2 = CKF1 with exception aggregation on CH3.
    Now, if you want to remove CH2 and have the 'before aggregation' behavior you will need to create another CKF3 = CKF2 with exception aggregation on CH2.
    ie for each level of aggregation, you will have to define a new CKF/Formula with corresponding exception aggregation - this is what will be needed to get you your output.
    Message was edited by:
            Ajay Das

Maybe you are looking for

  • Problem with SAP Screen

    Not sure if this is the correct forum. Okies, a user of mine has a problem with her SAP screens. It seems that she can't view the full screen of CJ20N She has to drag the window bigger to be able to see the content. She uses this window in a split mo

  • Maximum file handled using dom4j

    Hi, Wanna know whats the maximum xml file size that can be handled using dom4j. To be precise, I have a 1gb xml file that I wanna parse, I have implemented it using SAX, but wanna know if dom4j can be used? Regards, R

  • Help with uploading files through form

    Hey, I have a website for a sign business and I'm trying to make it so people can upload custom artwork. I am using an ASP Formmail script from I think it's www.brainjar.com. If I understood correctly from the directions, I can't upload files through

  • Create PW-Protected Site for a Club w/ Roster and E-mail capability

    I would like to create a site for a small club (50 members). It needs to be password-protected. I would like to have a roster (names, addresses, e-mail, etc.) that members could access and update. Then, I would like the members to be able to use this

  • Anyone have problems getting Office 2004 to run after Lion upgrade?

    Anyone have problems getting Office 2004 to run after Lion upgrade?