Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / How to convert wxString to floating point?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. How to convert wxString to floating point?
#3488
Posted by: mooncake 2004-03-10 22:11:16
Hi,
   I am using wxGrid.  I get the value from the cells, but it return wxString.
But, i need to get some of the cell of the value to do some calculating... Therefore, i need to convert it to floating point first, after convert back to wxString...

Anyone can teach me?

Thank you....
Meow~
Message2. Re: How to convert wxString to floating point?
#3491
Posted by: upCASE 2004-03-11 18:17:03
Hi!
To convert a string to a number use one of the following
ToLong()
ToULong()
ToDouble()
To convert a number into a string use Format() or Printf().
If you want your grid to take floating point variables you'll have to derive your own wxGridTable from wxGridTableBase and set your table as the underlying table for the grid using SetTable(). I'm currently doing something like that because I need a grid for displaying property values for a resoucre editor. By standard wxGrid uses a wxGridStringTable, that's why it stores all values as strings.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: How to convert wxString to floating point?
#3495
Posted by: mooncake 2004-03-11 19:50:12
Hi Upcase,
     Would you mind to show me the examples about  wxGridTable with wxGrid?
     Thank you.
Meow~
Message4. Re: How to convert wxString to floating point?
#3499
Posted by: upCASE 2004-03-11 22:00:21
Hi!
I'd really like to, but I'm not finished with it yet.
There is a sample for this though. Check out the grid example and browse the source looking for BugGridTable which is derived from wxGridTableBase and implements storing boolean values. Also the source for wxGrid itself is interesting, because there the "standard table" (wxGridStringTable) is implemented.
Maybe I find the time to do some more work on my PropertyGrid tonight and I can comment on my findings later on.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0