Results 1 to 40 of 47

Thread: Expandable Props [RESOLVED]

Hybrid View

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Expandable Properties

    Getting allot closer, but I still cant get this line to convert correctly.
    VB Code:
    1. gs.GradientMode = [Enum].Parse(GetType(GradientStyle), Trim(props(0)))
    When I wrap it with the CType it tells me that the GradientStyle is undefined?
    VB Code:
    1. gs.GradientMode = CType([Enum].Parse(GetType(GradientStyle), Trim(props(0))), GradientStyle)
    What am I doing wrong?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Expandable Properties

    Duh! I figured out! I needed to ctype it to a lineargradientmode and not a class.
    VB Code:
    1. gs.GradientMode = CType([Enum].Parse(GetType(GradientStyle), Trim(props(0))), LinearGradientMode)
    Now I have two issues left.
    1. Defaults are not Resetting to the correct values. I have the default attributes on each of the
      three properties but when I reset them it goes to Horizontal, 0, 0 and not ForwardDiagonal, White, Blue.

      Do I need to supply something different as a default since the prop is expandable?


    2. The gradient panel is not respondin at all to the property changes.
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Expandable Properties - Almost Solved but still a few "issues"

    Ok, now I get some kind of hex number for RGB colors?

    "ForwardDiagonal, ff7ba2e7, ff6375d6"

    I am trying to get the Reset right click context menu to function at the DrawStyles level just like it does
    for the Font property. The Font property lets you reset all the child properties at the top level with one
    click.

    I have the GradientMode, PanelColor1, and PanelColor2 all with the DefaultValues attrib, so I dont know
    what else to do to fix it?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: Expandable Properties - Almost Solved but still a few "issues"

    VB Code:
    1. Public Overloads Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object, ByVal destType As Type) As Object
    2.       If destType Is GetType(String) Then
    3.          ' Attempt to convert the value into a string representation
    4.          Try
    5.             Dim styles As DrawStyles = CType(value, DrawStyles)
    6.             m_lastValue = styles
    7.             [b]Return String.Format("{0}, {1}, {2}", styles.DrawMode, styles.Color1.Name, styles.Color2.Name)[/b]
    8.  
    9.          Catch ex As Exception
    10.             ' If there was an error, display it instead of the string value
    11.             Return String.Format("Error: {0}", ex.Message)
    12.  
    13.          End Try
    14.       End If
    15.       Return MyBase.ConvertTo(context, culture, value, destType)
    16.    End Function
    17. End Class

    The problem with the colors displaying as hex should be on the bold line.

    -----
    Default values:

    VB Code:
    1. Public Overloads Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object) As Object
    2.       If value.GetType() Is GetType(String) Then
    3.          [b]If IsNothing(Value) OrElse DirectCast(Value,String).Text.Length = 0 Then
    4.                  Dim x as New DrawStyles
    5.  
    6.                  x.DrawMode = Vertical
    7.                  x.Color1 = Color.White
    8.                  x.Color2 = Color.Blue
    9.                
    10.                  Return x
    11.          End If[/b]
    12.          Try
    13.             ' Attempt to parse the string representation
    14.             ' into the constituent properties
    15.             Dim ds As New DrawStyles
    16.             Dim s As String = value
    17.             Dim c As String
    18.  
    19.             Dim props As String() = s.Split(",".ToCharArray())
    20.  
    21.             ds.DrawMode = [Enum].Parse(GetType(DrawMode), Trim(props(0)))
    22.             c = Trim(props(1))
    23.             If Not IsNumeric(c) Then
    24.                ds.Color1 = Color.FromKnownColor([Enum].Parse(GetType(KnownColor), c))
    25.             Else
    26.                ds.Color1 = Color.FromArgb(Convert.ToInt32(c))
    27.             End If
    28.             c = Trim(props(2))
    29.             If Not IsNumeric(c) Then
    30.                ds.Color2 = Color.FromKnownColor([Enum].Parse(GetType(KnownColor), c))
    31.             Else
    32.                ds.Color2 = Color.FromArgb(Convert.ToInt32(c))
    33.             End If
    34.  
    35.             Return ds
    36.  
    37.          Catch ex As Exception
    38.             ' Revert back to the last good value if an error is encountered
    39.             ' trying to parse the entered "text" value for the constiuent properties
    40.             Return m_lastValue
    41.  
    42.          End Try
    43.       End If
    44.       MyBase.ConvertFrom(context, culture, value)
    45.    End Function

    I think that should do the trick
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  5. #5

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Expandable Properties - Almost Solved but still a few "issues"

    On ConvertFrom procedure I get an error stating that Text is not a member of string
    VB Code:
    1. If IsNothing(value) OrElse DirectCast(value, String).Text.Length = 0 Then
    2.  
    3. 'Would this be the same thing?
    4. If IsNothing(value) OrElse DirectCast(value, String).ToString.Length = 0 Then
    Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: Expandable Properties - Almost Solved but still a few "issues"

    I spaced...

    VB Code:
    1. If IsNothing(value) OrElse DirectCast(value, String).Length = 0 Then

    for some reason I was thinking it was a textbox
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  7. #7

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Expandable Properties - Almost Solved but still a few "issues"

    Cool getting even closer. But the top level prop only reset if I delete the concatinated string, but then it
    reset correctly. When I reset the top level prop it resets to horizontal, 0, 0 and not my custom defaults I
    added to each of the three child props. Do I need to add the defaults to the top level mailn prop too? Idf so
    then how since you cant have more then one?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width