[WPF] Format column text for showing percentage

Hi,
in one column of my DataGrid I show percentage values.
From database, I get the number:
- in view, I would concatenate the char "%"
- in edit, the user add his value and when mouse leaves cell automatically is concatenated the char "%"
How can I implement it?
Thanks.

Replace any DataGridTextColumn with a DataGridTemplateColumn and specify a StringFormat for the TextBlock in the CellTemplate only:
<DataGrid.Columns>
<!--<DataGridTextColumn Binding="{Binding Val, StringFormat=P}"/>-->
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Val, StringFormat='\{0\}%'}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding Val}"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
Note that the "number" source property must be an int, double, decimal etc. for the StringFormat to get applied.
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question.

Similar Messages

  • Change Date format to Text for Import

    I have used Sql Server Integration Services to extract some data into Excel.  When I load the files it seems that not all the time the dates are formatted with the time.  If I format the field this just changes the display value and not the underlying
    field value.  I have tried to copy the field into notepad, add a new field format this as text and then paste the desired format.  But this also does not
    always work.  Is there an easy way to change the date/time value so it is always in a consistent format to import into another system?  

    Hi SBolton,
    If I understand correctly, you want to change a column from Date data type to Text while importing data to Excel.
    If in this scenario, we can use Data Conversion Transformation or Derived Column Transformation to convert the original Date data type to Text data type, then use the new column maps to the corresponding Destination column.
    The following screenshots are for your references:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to get iPhone Safari to format text for its screen

    My wife loves her iPhone, but there's one thing that's very frustrating: Safari likes to format pages so that only a small portion fits on the screen, and you have to scroll left and right to read the text. If you use a "pinch" to shrink the window, the font size also shrinks so that the text becomes unreadable.
    I've tested this with a few very simple HTML pages that I've created, just text with a few andtags, and nothing with a width= or size= attribute. We still have the same problem. Safari doesn't seem to want to wrap the text at all; it either displays a page at a tiny font or in a readable font with most of the text off the screen.
    I've also tested these pages with assorted other browsers, including Safari and the other dozen browsers I've installed on this Macbook Pro. All of them automatically wrap the text to fit whatever size window I use, including some very tiny windows. Also, the browser on my G1 "google" phone handles the pages just fine, using my default font and reformatting automatically when I rotate the phone to landscape format so that the text fits within the window.
    The only browser I've seen this problem with is on the iPhone. found the Settings screen, looked through the Safari settings and didn't see anything relevant.
    Any ideas what's wrong here? Or is the iPhone's Safari just flakey for simple text?

    The pinching gesture is used to zoom in and out on a page. It's not resizing the window.
    OK; I obviously don't know the right jargon. That's why I posted on a general discussion "support" forum rather than looking for a more technical one; I was hoping that my incorrect n00b terminology could be tolerated enough for people to try to understand the problem and point at some clues.
    To try to explain it in different (and probably still not correct) terminology, Safari on the iPhone acts like it's formatting the text of even my simple HTML text pages for a large physical "page", and giving me a choice of how I want to view it. I can zoom out and see the whole piece of text, but the font is so tiny that it's unreadable (even with a magnifying glass . Or I can zoom in, in which case the screen becomes a small window that shows only a small portion of the text, and I have to pan left and right to read it, because the "page" width is now several times the screen width. Both choices make for slow, difficult reading.
    I don't see this behavior in any other of the couple dozen browsers on 4 or 5 machines. What they do is respond to a change in the "window" size by reformatting the text so it fits within the window's width, scrolling off the bottom if there's too much text. This is easy to read, because vertical scrolling works well on all of them, and there's no need to pan left and right while reading a line of text.
    This was pretty much how HTML and browsers were originally intended to work, with the browser doing line wrapping as needed to fit the available screen width. The screen as a window into a much larger page is seen much less often. When it is seen, it's mostly because the web designers included lots of "width=" attributes to force the page to be some minimum width, typically much wider that any smartphone's screen. But my test pages don't do this, and all other browsers successfully format them to be readable even in very narrow windows. Our iPhone's Safari doesn't seem to do this formatting; it formats the text for a width wider than the screen even when there's no formatting information in the HTML.
    The obvious question is: Can the iPhone's Safari be persuaded to use more common scheme of doing line-wrapping to make the text fit into the visible screen?
    The G1's browser has an especially impressive demo of how it could be done. If I rotate that gadget, it reformats between portrait and landscape mode on the fly, and the text is always line-wrapped to fit the current screen width. So a paragraph that takes, say, 7 lines in portrait mode will switch to 4 lines as I rotate it to landscape mode, with the same font size. The iPhone has the same sort of switching, of course, but it "reformats" the text by changing the zoom factor, which isn't nearly the same thing. And for some of my test pages, the text runs off the right margin in both portrait and landscape mode. I have no clue why it chooses a "page" width that's so much wider than the screen, sometimes 4 or 5 times the screen width, but that's what it does, and it's very hard to read.
    So is there a way to tell it to stop doing this, and use line wrapping like other browsers do to fit the text into the visible screen width?

  • How do I do use the custom code and format for a percentage with 2 decimals in Report Builder 3.0?

    In Report Builder 3.0, I have the following custom code entered:
      Public Function SafeDivide(Numerator as String, Denominator as String) as String
    Try
    If Numerator = “” or Denominator = “” then
    Return “-“
    End if
    If Numerator = “-“ or Denominator = “-“ then
    Return “-“
    End If
    If CDbl(Numerator) =0 or CDbl(Denominator) = 0 then
    Return “-“
    End if
    If IsNothing(Numerator) or IsNothing(Denominator) then
    Return "-"
    End if
    Return Val( ( (CDbl(Numerator) / CDbl(Denominator) )*100 ) )
    Catch
    Return "-"
    End Try
    End Function
    I call the custom code in the cell with the following equation:
      =Code.SafeDivide(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value),sum(Fields!LY_UNITS.Value))
    I have the format for the cell set to 0.00%, but it’s not being followed.
    I want the result to be formatted as a Percentage, but instead I get values like: 
    -78.9473684210
    80
    300
    -100
    I have the format for the cell set to 0.00%, but it’s not being followed.
    How do I do use the custom code and format for a percentage with 2 decimals?

    Hi AngP,
    After testing the issue in my local environment, I can reproduce it. Based on my research, I find this issue is caused by the type of Units_VAR_Percentage cell is string, while the type of CDbl(Parameters!Var_Threshold.Value) is double, so they cannot be
    compared.
    To fix this issue, we can add a hidden column (Textbox91) next to the Units_VAR_Percentage column, and type =(sum(Fields!TY_UNITS.Value)-sum(Fields!LY_UNITS.Value)) /sum(Fields!LY_UNITS.Value) as the expression. Then use the expression below to control the
    BackgroundColor:
    =iif(iif(reportitems!Units_VAR_Percentage.Value=CStr(format(reportitems!Textbox91.Value,"0.00%")),reportitems!Textbox91.Value,0)>CDbl(Parameters!Var_Threshold.Value),"Yellow","PaleTurquoise")
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • ADF Faces tooltip text for datatable's columns impossible?

    Hi,
    How can I show tooltip text for column in datatable? ShortDesc property for column is ignored.
    thanks,
    Branislav

    Hi Brano,
    this is a small workaround:
      <af:table rows="5">
        <af:column>
          <f:facet name="header">
            <af:panelGroup layout="vertical">
              <af:outputText value="Ako ide ADF?"/>
              <af:outputText value="Small blue tooltip"
                                    inlineStyle="font-size: 70%; color: blue"/>
            </af:panelGroup>
          </f:facet>
          <af:outputText value="#{row.col2}"/>
        </af:column>
      </af:table>Rado

  • Format Column Header in Crosstab Query in Crystal Reports for Enterprise

    Hi
    I am using Crystal reports for Enterprise and I would like to format the Column header of a crosstab query one block of colour say light blue.  However I cannot select the header in isolation to the rest of the cross tab.  All I can select is either column text boxes, which doesnu2019t look good formatted as a different colour to the background of the crosstab.  Or I can only select either entire column or the entire row, which kind of defeats the object of formatting just the column header itself.  Is there a way to isolate the column headers so I can format just the header, as the report is looking extremely bland all in white?
    Many Thanks in advance
    Regards
    Neil

    Alright, here's what you need to do:
    1) RIght-click one of the Column Headers and select 'Format Result Object Element' > Appearance > click on the formula button (fx) beside 'Fill' and use this code:
    if currentrowindex < 0 then crBlue
    You wanted light blue right? So, the rgb value for light blue or sky blue would be 135-206-250. So, you can change the color by modifying the formula like this:
    if currentrowindex < 0 then color(135,206,250)
    If this is not the exact blue you're after, just google!
    Hope this helps!
    -Abhilash

  • Report doesnt show the text for employee ids.....

    Hi guys,
    I am facing the following issue.
    We have a report which is fetching data from the infocube.Whenever we check the report we are facing the issue : report doesnt show the text for ~10 employee ids,its showing the key in both key and text columns, its showing both text and key for the remaining employee ids.We checked the master data for employee id and it contains master for the employee ids which are not displayed text in the report.
    Can any body help on this.
    Regards
    Prasad

    Hi Prasad,
    for your infoobject do you have all three texts available (short, medium and long)? Are all three loaded? You might have the wrong text displayed in your report. Check if you have the short, medium or long texts displayed. Dont forget to check the languages too ....
    Kind Regards,
    Alex
    Edited by: Alexandre Soares on Dec 2, 2008 3:33 PM

  • When saving a page under text format, the text is limited to 80 columns only, how to extend to 120 columns

    When I save a page under text format, the text is limited to 80 columns only, how to extend to 120 columns (or more)?

    HI K,
    This is the Numbers (Mac OS) forum. Your question about Numbers for iOS will probably get better results posting in the iWork for iOS area. the link will take you there.
    Regards,
    Barry

  • Database Column Type for Rich Text Editor

    Hi,
    I have a page item as Rich Text Editor. Now I want to store the data in tables in the same format as user entered in the page item.
    What would be the database column type for that?
    Thanks,
    Mehabub

    Mehabub Sheikh wrote:
    I have a page item as Rich Text Editor. Now I want to store the data in tables in the same format as user entered in the page item.
    What would be the database column type for that?As usual, the answer is "It depends".
    In this case it depends on the nature and size of the content. For content up to 4000 bytes in length, use VARCHAR2 or NVARCHAR2 (depending on the DB character set and globalization requirements), for content of longer length use CLOB or NCLOB (again depending on DB characterset and your globalization requirements).
    Note the effect of DB character set on the number of characters you can store in a VARCHAR2 or NVARCHAR2 column, and the overhead of HTML tags generated by formatting in the Rich Text Editor.

  • I have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

    i have problem with fonts for my site, i have used "Lucida sans unicode " family for certain texts. it shows perfect in mozilla 3.5 and mozilla 4. But the font not supporting in mozilla 5.0? please help me

  • ICal doesn't show all text for the activity

    When I updated to iCal version 8.0 i noticed that when I am in week-view, iCal doesn't show all the text for an activity, although there is plenty of room. For example I have a lecture from 9 am - 4 pm and in the activity I put down all the things I have to do, but it only shows the first line for my activity. I need to drag the box or double click on it to see all the text. Can I change this?

    Gabriella,
    Sometimes making the Calendar window bigger, or using full screen allows additional text to be displayed.
    View>"Make Text Smaller" is also an option for those with Eagle Eyes.

  • Requirment Urgent: How to format standard text in Script like two columns.

    Hi,
    I want to format the text in two columns like this.
    1. This is the note. 5. This is the note.
    2. This is the note. 6. This is the note.
    3. This is the note. 7. This is the note.
    4. This is the note. 8. This is the note.
    I have to include a standard text and format like this.
    Thanks in advance.

    Hi,
    You have to create a paragraph format and create two tabs according to your column positions.
    and write.
    ,,&column1& ,,&column2&
    Regards,
    Wasim Ahmed

  • How to set title/text for ALV table column header in WD ABAP

    Hello,
    I am working in WDA using SALV_WD_Table to display data in table. I need to change the column header text, the obvious way is to get the column header and call the method SET_TEXT to set new text / title. However, this method does NOT work, it does not change the column header text. I also tried the SET_TOOLTIP, this one works, but SET_TEXT does not work. Anyone has idea why this not working and do you find any go-around solution?
    My version is NW 7.0
    Thank
    Jayson

    Hi jason ,
    For setting Heder text for your ALV table
    ip_confing type ref to CL_SALV_WD_CONFIG_TABLE.
    "set alv table header
      ip_config->if_salv_wd_table_settings~r_header->set_text( 'Test ALV Header functionality' ).
    first you have to hide the DDIC text and then try to set your own text .
    "modify columns
      LOOP AT lt_columns INTO ls_column.
        lr_column = ls_column-r_column.
        CASE ls_column-id.
          WHEN 'MANDT'.
            "hide this field
            lr_column->set_visible( cl_wd_abstr_table_column=>e_visible-none ).
           WHEN 'SEQNR'.
            "set header to different string
            lr_column->r_header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none )." use this line to hide ddic text
            lr_column->r_header->set_text( 'Position' ).     
        endcase.
      endloop.
    Regards
    Chinnaiya P

  • How to display a Column Header for the characteristic Text column

    Hi All
    Our users want me to provide for a column header for the characteristic text.
    Here is what I mean
    I am reporting 0plant in the rows as key and Text. In the column on Plant Key the column header says Plant but there is no column header for the plant text.
    Eq:
    Plant                                                        Amount
    IE00         Initiator Plant                               244
    IE01         Initiator Plant NJ                          890
    Our users in the plant text column want a dummy column header to be displayed. SInce they download the data from the BW report to Excel and use pivot reporting. How can I introduce a column header for the texts.
    Thanks
    Karen

    Hi Karen,
    I am not sure if this is possible, although Users can ask anything :).
    In Planning we used to predefine cell headings via Macros and creating dummy cells in between.  I am not sure if a similar scenario can work here.
    By default this is not possible in Reports.  In BEx workbooks, you could probably try with Macros.
    Another easy option is to bring the data in the Cube as another field or create a nav. attribute in the master for text and use it as a nav. attr. in the Cube and put it in your Query row alongside.
    -Aby

  • FM9: Show conditional text for entire book -- how?

    In FM8, I would select all the docs in my book, then choose Special>Conditional Text>Show/Hide Conditional Text to display the conditional text dialog. Choose my display options (specific conditions, or Show All), then apply. Voila!
    In FM9, I can't seem to figure out how to do it. If I follow the same steps, when the dialog appears, all of the options are 'greyed out'.
    Help?

    Hmmm.... nope :-)
    Okay, I opened up my book (contains 17 documents, at least 12 of them have conditional text). I have two of the documents displayed so that I can see what's going on.
    To 'show all' conditional text for a specific document:
    - Click in the document to give it focus.
    - Click Show/Hide Conditional Text to display the pod.
    - Select Show All and click Apply.
    - Success, for that document.
    To 'show all' conditional text for the entire book:
    - Click in the book pod to give it focus.
    - Ctrl+A to select all the documents (all docs are now highlighted)
    - View > Show/Hide Conditional Text... to display the pod.
    - All options are grayed out, and no conditions appear in the Show or Hide lists.
    Am I missing a step somewhere (or more likely, am I doing this totally incorrectly)?
    Thanks!

Maybe you are looking for