CompletIT Community Server

Welcome to CompletIT Community Server Sign in | Join | Help
in Search

How in VB.Net can I set a saved theme

Last post 01-09-2008, 9:43 AM by iiordanov. 1 replies.
Sort Posts: Previous Next
  •  01-07-2008, 8:25 AM 1415

    How in VB.Net can I set a saved theme

    hello, 

    In runtime I've created/saved 2 themes "Luc_A" and "Luc_B" and I can switch between these 2 themes.
    Now I want to change the theme in Visual Basic code.
    Something like :

    Public Shared Function CompletIT.Windows.DataGridViewExtension.DataGridViewExtension.ChangeTheme(ByVal aDataGridViewControl As System.Windows.Forms.DataGridView, ByVal ThemeName As String)

    => in code
    Imports CompletIT.Windows.DataGridViewExtension()


    Private m_DGVExtension As DataGridViewExtension = New DataGridViewExtension


    Private Sub cmdChangeTheme_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdChangeTheme.Click
       
        m_DGVExtension.ChangeTheme(myDataGridControl, "Luc_B")

    End Sub


    Is this already possible or a possible future function ?

    Greets, Luc

  •  01-09-2008, 9:43 AM 1428 in reply to 1415

    Re: How in VB.Net can I set a saved theme

    Hi Luc,

    Yes, it is possible to change the selected theme for a grid but this functionality is not well tested because it was not meant to be used externally. In next versions we are going to provide a better way for changing a theme using the API.

    There are two things you should know to change a theme:

    1. You can obtain list of all available themes using the SavedThemes property of DGVEThemesManager class. In order to find a desired theme by name iterate through the collection and check the property SettingsName:
        
       Dim Themes As BindingList(Of DGVENotDataSourceSpecificSettings) = DGVEThemesManager.SavedThemes

    2. To change a theme you actually have to copy the theme settings (in your case from theme 'Luc_A' or 'Luc_B') to the settings that are currently applied to the DataGridView control. Bellow you can see the code snippet how to change the theme of a control 'dataGridView' with a selected theme.

       Dim Themes As BindingList(Of DGVENotDataSourceSpecificSettings) = DGVEThemesManager.SavedThemes
       Dim MyTheme As DGVENotDataSourceSpecificSettings = ...'Find the desired theme by name

       'Suspend persistence and event handling
       DataGridViewExtensionComponent.Extension.SuspendPersistenceOfSettingsForDataGridViewControl( dataGridView )
       DataGridViewExtensionComponent.Extension.SuspendEventHandlingOfSettingsForDataGridViewControl( dataGridView )

       'Copy the settings from the theme to the current settings of the grid view control

       MyTheme.CopyTo( DataGridViewExtensionComponent.Extension( dataGridView ).NotDataSourceSpecificSettings )

       'Resume persistence and event handling
       DataGridViewExtensionComponent.Extension.ResumeEventHandlingOfSettingsForDataGridViewControl( dataGridView )
       DataGridViewExtensionComponent.Extension.ResumePersistenceOfSettingsForDataGridViewControl( dataGridView )

       'Force save of the changes
       
    DataGridViewExtensionComponent.Extension.ForcePersistenceOfSettingsForDataGridViewControl( dataGridView, PersistedSettingsType.All )
       DataGridViewExtensionComponent.Extension.ForceApplyingOfSettingsToDataGridViewControl( dataGridView )

    NB! Keep in mind that DataGridView Extension manages the grids when visualized for first time, and if you try to obtain the settings 'DataGridViewExtensionComponent.Extension( dataGridView )' for a grid view control before that moment you will get null(Nothing).

    If you have any other questions do not hesitate to ask us.

    Yours Sincerely,
    Support Team

    Filed under:
View as RSS news feed in XML
Powered by Community Server (Personal Edition), by Telligent Systems