How To Get rid of Exponential format in datagridview when the number is very large

When the number is very large like :290754232, I got 2.907542E +08. in datagridview cell
I using vb.net , framework 2.0.
how can I get rid of this format?
Thanks in advance

should I change the type of this column to integer or long ?
The datagridview is binded to binding source and a list ( Of).
Mike,
I'll show you an example that shows the correct way to do this and a another way if you're stuck using strings in exponential format. The latter being the "hack way" I spoke about Friday. I don't like it, it's dangerous, but I'll show both anyway.
In this example, I'm using Int64 because I don't know the range of yours. If your never exceeds Int32 then use that one instead.
First, I have a DataGridView with three columns. I've populated the data just by creating longs starting with the maximum value in reverse order for 100 rows:
The way that I created the data is itself not a great way (there's no encapsulation), but for this example "it'll do".
Notice though that the third column (right-most column) isn't formatted at all. I commented out the part that does that so that I could then explain what I'm doing. If it works, it should look like the first column.
The first column represents an actual Int64 and when I show the code, you can see how I'm formatting that using the DGV's DefaultCellStyle.Format property. That's how it SHOULD be done.
The third column though is just a string and because that string contains a letter in it, Long.TryParse will NOT work. This is where the "hack" part comes in - and it's dangerous, but if you have no other option then ...
You can see that now the third column matches the first column. Now the code:
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
With DataGridView1
.AllowUserToAddRows = False
.AllowUserToDeleteRows = False
.AllowUserToOrderColumns = False
.AllowUserToResizeRows = False
.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine
.ReadOnly = True
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.MultiSelect = False
.RowHeadersVisible = False
.RowTemplate.Height = 30
.EnableHeadersVisualStyles = False
With .ColumnHeadersDefaultCellStyle
.Font = New Font("Tahoma", 9, FontStyle.Bold)
.BackColor = Color.LightGreen
.WrapMode = DataGridViewTriState.True
.Alignment = DataGridViewContentAlignment.MiddleCenter
End With
.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
.ColumnHeadersHeight = 50
.DataSource = Nothing
.Enabled = False
End With
CreateData()
End Sub
Private Sub CreateData()
Dim longList As New List(Of Long)
For l As Long = Long.MaxValue To 0 Step -1
longList.Add(l)
If longList.Count = 100 Then
Exit For
End If
Next
Dim stringList As New List(Of String)
For Each l As Long In longList
stringList.Add(l.ToString("e18"))
Next
Dim dt As New DataTable
Dim column As New DataColumn
With column
.DataType = System.Type.GetType("System.Int64")
.ColumnName = "Actual Long Value (Shown Formated)"
dt.Columns.Add(column)
End With
column = New DataColumn
With column
.DataType = System.Type.GetType("System.String")
.ColumnName = "String Equivalent"
dt.Columns.Add(column)
End With
column = New DataColumn
With column
.DataType = System.Type.GetType("System.String")
.ColumnName = "Formated String Equivalent"
dt.Columns.Add(column)
End With
Dim row As DataRow
For i As Integer = 0 To longList.Count - 1
row = dt.NewRow
row("Actual Long Value (Shown Formated)") = longList(i)
row("String Equivalent") = stringList(i)
row("Formated String Equivalent") = stringList(i)
dt.Rows.Add(row)
Next
Dim bs As New BindingSource
bs.DataSource = dt
BindingNavigator1.BindingSource = bs
DataGridView1.DataSource = bs
With DataGridView1
With .Columns(0)
.DefaultCellStyle.Format = "n0"
.Width = 150
End With
.Columns(1).Width = 170
.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Enabled = True
End With
End Sub
' The following is what I commented
' out for the first screenshot. ONLY
' do this if there is absolutely no
' other way though - the following
' casting operation is NOT ADVISABLE!
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles DataGridView1.CellFormatting
If e.ColumnIndex = 2 AndAlso e.Value.ToString IsNot Nothing Then
' NOTE! The following is dangerous!
' I'm going to use coercion to force the
' string into a type long. TryParse will
' NOT work here. This can easily throw an
' exception if the string cannot be cast
' to a type long. I'm "depending on" the
' the string to cast. At the very least
' you might put this in a Try/Catch but
' that won't stop it from failing (if
' it doesn't work).
Dim actualValue As Long = CType(e.Value.ToString, Long)
Dim formattedValue As String = actualValue.ToString("n0")
e.Value = formattedValue
End If
End Sub
End Class
Like I said, only use that hack way if there's no other option!
I hope it helps. :)
Still lost in code, just at a little higher level.

Similar Messages

  • How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP server

    In 9iAS 9.0.2 Oracle HTTP Server (OHS) is pre-configured to assign requests to the Home OC4J instance via the URL-prefix "/j2ee"/
    For example, the TEST servlet under OC4J would be passed through OHS using:
    http://urmachine:urApachePort/j2ee/TEST
    whereas in the standlone OC4J version, this URL works:
    http://urmachine:urOC4JPort/TEST
    How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP Server?

    It is getting the url prefix from mod_oc4j.conf
    under /ora9ias/Apache/Apache/conf
    You can read more on this at
    http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/web.902/a92173/confmods.htm#1008977
    -Prasad

  • How do get rid of a tab group without closing the tabs? How do I take tabs out of a group?

    I accidentally put all my tabs in one group. I'd like to get rid of the group without closing all the tabs in it; in other words, to undo putting all the tabs in one group. It would be useful to know how to remove a tab from a group without closing the tab, accidentally putting a tab in the wrong group will probably be a common error that needs to be easily undone.

    '' SisqB;''
    ''I searched about:config and found a listing of "stuff" under the S3 Downloads ''
    Can you take a snapshot of what you see?
    In order to better assist you with your issue please provide us with a screenshot. If you need help to create a screenshot, please see [[How do I create a screenshot of my problem?]]
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. This will help us to visualize the problem.
    Thank you!

  • How to get rid of rpc.html pop up when browser opens

    when using firefox with my comcast home page, i get a pop up saying you have chosen to open rpc.html. how can i get rid of this?

    My guess is that there is a "hot spot" that when the cursor rolls over this area it triggers the download of the obnoxious rpc.html coding that drops into a person's download file. Now why someone would go to the trouble of setting up this type of non-consequential ruse if beyond me. Maybe this is just an errant html code glitch? It seems to be localized between Firefox and Comcast (Xfinity). Funny that one message says that each side to this problem is pointing the accusing finger toward the other. Glad, for a change, the computer user is not incorrectly targeted as the source of the problem.
    But the issue of a set of volunteers working on the problem and not being able to fix it is disturbing. Hope they (whomever) can solve the puzzle.
    I am finding my computer is not able to download Open Office for some reason. Spent ten hours trying to figure this out. Just gave up. I like Firefox but if I continue to have these types of problems, even if not proven to be related, I am going to have to find another solution, somewhere.

  • How to get rid of text in bookmark toolbar? the default reset will not work

    my bookmark toolbar has changed. I clicked on default reset so just icons show but it will not work. can not get rid of text.

    The Bookmarks Toolbar, by default, shows both icons and text. Here is an Add-on that will allow you to show only the icons.
    *'''''Roomy Bookmarks Toolbar''''': https://addons.mozilla.org/en-US/firefox/addon/roomy-bookmarks-toolbar/
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • How do I get rid of xml tags but not when the tag has copyright in it?

    I tried this but it does not seem to do anything:
    temp_string=temp_string.replaceAll("\\<.*?(!copyright)\\>", "");An example of this is that if I have: <meta name ="copyright" > I do not want to get rid of the tag. In other words, I do not want to get rid of any tags that have the word "copyright" in them, but I want to get rid of all other tags.
    Edited by: setaret2004 on Dec 16, 2008 4:11 PM

    setaret2004 wrote:
    Also if I want to include license as well do I just do: str = str.replaceAll("<(?![^<>]*(copyright|license))[^<>]*>", ""); Is that correct?Yes, you can do the same thing with all three regexes. Now, explanations:
    "<(?![^<>]*copyright)[^<>]*>" This regex does one lookahead, scanning forward for the word "copyright" before beginning the actual match. It's a negative lookahead, so if the word is seen, the lookahead fails and so does the overall match. If the lookahead succeeds, the match position is returned to where the lookahead started and the real matching begins.
    A naïve approach would use ".&#x2A;" or ".&#x2A;?" in the lookahead, but then it would be free to scan past the end of the tag and find the word in the next tag or halfway through the document; lookaheads are slippery that way. But I used "[<>]&#x2A;", so once it reaches the closing ">" it stops scanning.
    That means, for every successful match the regex scans the whole tag twice--once for the lookahead and once "for reals". That won't be a problem in most cases, but if you're matching many large chunks of text, performance could suffer. Each of the other regexes only traverses the tag once. "<(?:(?!copyright)[^<>])*>" This one steps through the text one character at a time, at each position doing a negative lookahead before matching the character. That sounds like a lot of work, but in the vast majority of cases the lookahead will only have to look at one character before yielding.
    "<(?:(?!copyright|[<>]).)*>" This is basically the same as the second regex, but it does all the real work in the lookahead. I don't recommend it; it's less readable and probably less efficient than the second regex. But both the second and third regexes can be made more efficient by using [possessive quantifiers|http://www.regular-expressions.info/possessive.html] (that whole site is highly recommended, by the way): "<(?:(?!copyright)[^<>])*+>", "");
    "<(?:(?!copyright|[<>]).)*+>" The first regex can use a possessive quantifier, too, but not in the lookahead: "<(?![^<>]*copyright)[^<>]*+>"

  • How to get rid of blue bar at top when tethering?

    I would like to get rid of the blue bar at the top og my Iphone 4 when it is tethering its internet connection. What is interesting is my girlfriends iphone does not show this blue bar when tethering. Instead it shows a small icon in the top left next to the signal indicator. Could this be a carrier tweak. We both use AIS in Bangkok Thailand but her phone was originally bought from True mobile and mine was bought in China at an Apple store. Of course it is not a fake Iphone for any of you skeptics. I checked the serial with Apple in canada and it is real. I even had it in for free warranty repair one time in Bangkok.  Any help would be appreciated. I don't like this blue bar and want mine to appear like hers. It cuts the screen shorter and limits my use of the phone while tethering.

    use following add on
    https://addons.mozilla.org/en-US/firefox/addon/app-button-remove/?src=api
    it will removes the orange button of left hand side ,see the attached image what will this add on do

  • How to get rid of "Oracle Portal" label(text) when mouse is over Logo.gif image

    In several portal screens (for example:
    Add Item wizard, Create Folder wizard,
    Create Page Style Wizard, Account Info screen, Create Page wizard, Create Application Wizard, etc, etc.... )
    there is like a Banner with the Logo.gif image and the text "Oracle Portal" displayed when the mouse is OVER Logo.gif
    I know how to replace this image with our own file, but what i would like to know how to replace or eliminate the "Oracle Portal" text.
    I imagine the information for this Template is stored somewhere in the database.
    I will appreciate if someone can help me to identify where is located this info so I can delete/replace the text.
    Any other suggestions will be wellcome.
    Tks in advance
    null

    Malin,
    when you install iAS, there is a directory
    oracle_home\portal30\images where all the image files are stored.
    for example, in my installation is:
    D:\oracle\iSuites\portal30\images
    one of the files is logo.gif, just overwrite that file with your own file (but keep the same name) and then your own logo or whatever you want will show up in the Portal.
    pls note that there are different image files you may want to replace.
    i hope it helps...
    null

  • TS2446 I forgot my apple password how cna get rid of that even i asked for the password receovery as well but no mail came till now

    I forgot my apple password and my user id is my current gmail account but whenever i am asking for password receovery, the message is showing that the mail sent but in actual there is no any such mail in my gmail account at all.....
    Plz help dear fast.....

    You haven't got a rescue email address on your account that the email could be being sent to, and you've checked the spam folder as well as the inbox ? If you aren't receiving the email then try contacting Support in the country where you and you iTunes account are to get the password reset : http://support.apple.com/kb/HT5699

  • How to get rid of advertisements that appear on both the left and right of my web browsers

    Recently i noticed that when i open either Firefox or Safari, the page will load but a few seconds later, two identical ads appear on both sides of my browser and partially obstructing the webpage that i'm on... PLEASE HELP!
    this is what it looks like.... http://i43.tinypic.com/2q8aj9s.jpg

    Make sure 'block pop-ups' is selected in both browsers.
    Firefox Preferences>Content tab; Safari Preferences>Security tab.
    For both browsers download AdBlock:
    Firefox - https://addons.mozilla.org/en-US/firefox/search/?q=AdBlock&cat=1%2C0&appver=11.0 &platform=mac
    Safari - https://extensions.apple.com

  • How to get siri to recognize another contact name, when the contact name she has does not exist.

    Siri could not understand me when I asked it to call my husband, (he has a name I have a hard time pronouncing) so I put in a middle name for siri to understand.  I then deleted the middle name from his contact, however, siri still tries to text/call that contact when prompted even though it does not exist.

    Hi Romano & Detlev ,
    Thanks for the reply .
    This is what I was looking
    Detlev:
    About the NPE ... in the above code I am not getting that.
    Thats my mistake
    Earlier I tried with
    IResource rsrPublished  = (IResource)event.getParameter();
    String rid = rsrPublished.getRID().toString();
    In the second line of code I was getting the NPE
    after that I used to if condition to debug it
    Sorry for the confusion...
    One more thing
    which is the event triggered for approval or how to capture the Approval Event when a content is approved by the Approver
    thanks
    pk

  • How do I create a shared library from iPhoto when the file is too large to burn on DVD?

    I  need to remove some photos (70 GB) to relieve a full hard drive.  I have exported and burned .jpg images on DVDs, but that is only useful as a worst case backup.  What I would like to have is a separate iPhoto Library for each calendar year of photos, so I could still view them in the albums and folders I have created to organize them.  I have done this before in an earlier version of iPhoto, and was able to create 2003 iPhoto Library, 2004 iPhoto Library, etc.  I put a copy on DVD (the full year fit on 1 DVD) and another copy on an external drive. 
    I am having problems doing this with iPhoto '09 (version 8.1.2).  The iPhoto library for each year is too large to burn on DVD.  When I select certain albums from the year that will fit on DVD and use the Share>Burn commands, it creates a library with Events and Faces, but none of the albums are listed on the left.  The albums are important to organize the photos for viewing (birthdays, vacations, holidays, etc.)  I didn't always pay attention to labeling Events when I imported photos, so that is not an adequate alternative to my albums.
    I was thinking that if I could create a library for the entire year, it might include my albums and folders. I would have space for this on my external hard drive.  However, I can find no way to create a library for the entire year and put it on my external drive - the only option is to burn a DVD or export .jpg images.
    Any suggestions would be appreciated.

    Best suggestion: Buy some external USB or Firewire drives. Move your Library to one, back it up to another. A lot more reliable than DVD, a lot less work and much more convenient. For a start, you don't have to break up the library...
    Regards
    TD

  • On iTunes when i plug my iphone in, the bar at the bottom with contains the information about the capacity of my iphone, it has a bar called 'other' which has 4GB. I don't know what is taking up that space or how to get rid of it. please help :)

    On iTunes when i plug my iphone in, the bar at the bottom with contains the information about the capacity of my iphone, it has a bar called 'other' which has 4GB. I don't know what is taking up that space or how to get rid of it. please help

    You can reduce the size to normal, which is about 1GB, by restoring the phone.
    Backing Up, updating, and restoring your iPhone and iPod touch software
    The size of this part can increase when something goes wrong during a sync, or some files can't be read anymore by iTunes.

  • How to get rid of Adobe Reader on my OSX 10.9.5

    I have a Mac mini, using OSX 10.9.5 and was forced to download Adobe Reader by Public Works, government of Canada, in order to print their document.  For starters this is SO wrong.
    When I completed the download, Adobe Reader wanted me to approve it replacing my Preview, which I didn't want to do, so I answered NO. 
    Now I can't get into the damnable Adobe Reader to get rid of it. 
    Can you please let me know how to get rid of ALL of Adobe Reader from the download?
    Thanks in advance for your anticipated help.

    Macintosh HD > Library > Internet Plug-ins
    Look for these two files.
    AdobePDFViewerNPAPI.plugin
    AdobePDFViewer.plugin
    Right click on those and select “Move To Trash”.
    Restart the computer.

  • HT204406 "Error 4001 with iTunes Match" does anyone know how to get rid of it?

    When trying to setup Match with Itunes I get error message 4001. Does anyone know how to get rid of this? I am on the most current version of Mountain Lion and I have upgraded to the latest version of iTunes. Error message occurs every time I try to setup match.

    Yep! I got the same thing. (and the failure to launch full screen mentioned elsewhere).
    Please let me know if you find a way to sort this out.
    Ta!

Maybe you are looking for