Using type "string" as type "VerticalAlign" 
Author Message
 Using type "string" as type "VerticalAlign"

I'm trying to set the vertical alignment of a TableCell object by passing
the variable "sVAlign"
The system expects type "VerticalAlign"
I have tried to cast the string like:

string sVAlign = "Left";
TableCell oCel = new TableCell();

oCel.VerticalAlign = VerticalAlign.Left    // This works
oCel.VerticalAlign = (VerticalAlign)sVAlign;    // This doesn't

Any thoughts of how to convert the string to VerticalAlign?



Sun, 21 Mar 2004 05:50:53 GMT  
 Using type "string" as type "VerticalAlign"
Troy,

Quote:
>string sVAlign = "Left";

Left is not a member of the VerticalAlign enumeration. You either have
the wrong name, or you want to use the HorizontalAlign enumeration
instead.

Quote:
>Any thoughts of how to convert the string to VerticalAlign?

For any enumeration type, you can do

EnumType enum_var = (EnumType) Enum.Parse( typeof(EnumType),
"MemberName" );

Mattias

===
Mattias Sj?gren (VB MVP)

http://www.msjogren.net/dotnet/



Sun, 21 Mar 2004 06:18:33 GMT  
 Using type "string" as type "VerticalAlign"
Sorry, it was actuallly "Top", not "Left", but I'm trying to do the same. I
just created a function that returns either a Vertical or Horizontal align
when passed a string.
That seemed to do it.


Quote:
> Troy,

> >string sVAlign = "Left";

> Left is not a member of the VerticalAlign enumeration. You either have
> the wrong name, or you want to use the HorizontalAlign enumeration
> instead.

> >Any thoughts of how to convert the string to VerticalAlign?

> For any enumeration type, you can do

> EnumType enum_var = (EnumType) Enum.Parse( typeof(EnumType),
> "MemberName" );

> Mattias

> ===
> Mattias Sj?gren (VB MVP)

> http://www.msjogren.net/dotnet/



Sun, 21 Mar 2004 07:34:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Variables and types of type "Type"

2. "string" data type in C++

3. The "using" declaration and protected types

4. "Windows data types" vs "c data types"

5. remove() vrs fopen("""w")

6. Displaying binary data as ascii "1"'s and "0"'s

7. Looking for "Shroud"/"Obfus"

8. ""help with TSR""

9. Parse trees and "("")"

10. Error "free"-ing "malloc"-ed memory

11. Displaying binary data as ascii "1"'s and "0"'s

12. "hooking" into a specific file type

 

 
Powered by phpBB® Forum Software