Inch / Metric value

  • Thread starter Thread starter Rainer Queck
  • Start date Start date
R

Rainer Queck

Hi NG,

in a dataset.datatable I have rows, containing metric data as doubles.
I need to display/edit these values in textboxes depending on the culture
(Metric/Inch). Is there something like a built in conversion functionality
for that in the framework / visualstudio or do I have to do these
conversions manually?

Thanks for help and hints
Rainer
 
Mark said:
There's nothing built-in, but it really has to be one of the simplest things
to write...

Sure, but it's always nice to check first to make sure you're not
re-inventing the wheel.

No, there isn't, but there should be. Just as I was surprised to find
no framework support for loading currency conversion rates and doing
currency conversions. Not that MS could somehow provide the conversions
themselves, just some kind of standard way of loading and using them
would be nice.

Same with units of measure and unit conversions: it would be nice if MS
would just build them into the framework. Yes, they're dead simple and
100% internationally standard, but then how many people have written
them over and over again, all over the world? All the more reason to
toss them in the .NET Framework, IMHO.
 
Hi Rainer,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you have a column containing data in
Metric data and you need to display and modify it in Metric/Inch accroding
to the user settings. If there is any misunderstanding, please feel free to
let me know.

Generally, you need to do the conversion from Metric to Inch and backward
yourself. But if you only need to do the display, there is a simpler
solution. You can add another column with an expression to the current
DataTable. The new expression column counts from Metric to Inch with an
expression. For example:

ExpCol.Expression = "OrigCol/2.54";

Then bind certain textbox to the ExpCol to display the inch data. However,
the expression column is read-only and you cannot modify the value directly
in that column. If user changed the value in the textbox, count the value
for the OrigCol, and modify the OrigCol in DataTable and the ExpCol value
will change automatically.

HTH.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Bruce,
Sure, but it's always nice to check first to make sure you're not
re-inventing the wheel.
You caught my thought ;-)

No, there isn't, but there should be. Just as I was surprised to find
no framework support for loading currency conversion rates and doing
currency conversions. Not that MS could somehow provide the conversions
themselves, just some kind of standard way of loading and using them
would be nice.

Same with units of measure and unit conversions: it would be nice if MS
would just build them into the framework. Yes, they're dead simple and
100% internationally standard, but then how many people have written
them over and over again, all over the world? All the more reason to
toss them in the .NET Framework, IMHO.
You have my vote on that!

Rainer
 
Hi Kevin,

thanks for your responds.

Kevin Yu said:
Generally, you need to do the conversion from Metric to Inch and backward
yourself.
It's a pity. I am quit new to the framwork, but the functionallity I
experienced up to now is really great!
Thats why I was hoping, that this kind of "commonly needed" functinallity
would be in it. Well...
But if you only need to do the display, there is a simpler
solution. You can add another column with an expression to the current
DataTable. The new expression column counts from Metric to Inch with an
expression. For example:

ExpCol.Expression = "OrigCol/2.54";
This is how I have done it in the meanwhile.
Then bind certain textbox to the ExpCol to display the inch data. However,
the expression column is read-only and you cannot modify the value
directly
in that column. If user changed the value in the textbox, count the value
for the OrigCol, and modify the OrigCol in DataTable and the ExpCol value
will change automatically.
Yes, I think this is how I will approach the issue.

Thanks
Rainer
 
You're welcome, Rainer. Good luck! If you have anything unclear, please
feel free to post it in the community.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top