0

I'm trying to create a very simple WPF application to test Syncfusion Grid in VB.NET

I created a simple window and inserted in the designer a ScrollViewer and a Syncfusion GridControl inside it.

this is the window xaml

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ExpenseIt"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="Window2"
        mc:Ignorable="d"
        Title="Window2" Height="300" Width="537.398">
    <Grid>
        <ScrollViewer HorizontalAlignment="Left" Height="194" Margin="10,10,0,0" VerticalAlignment="Top" Width="380">
            <syncfusion:GridControl Height="100" Width="100"/>
        </ScrollViewer>

    </Grid>
</Window>

Now I tried to create an instance of the grid in the corresponding xaml.vb file

Public Class Window2
    Dim gridControl As Syncfusion.Windows.Controls.Grid

    Private Sub Window2_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded

    End Sub
End Class

But the "Dim" line shows an error says it expect type. What I'm doing wrong?

2
  • Could you show a bit more code please, the xaml Commented Sep 28, 2017 at 11:37
  • I edited my question adding some code. Hoping it helps Commented Sep 28, 2017 at 12:53

1 Answer 1

1

You are creating an instance of the GridControl in your XAML. Give it an x:Name:

<syncfusion:GridControl x:Name="grid" Height="100" Width="100"/>

...and you can access this instance in your code-behind using this name:

Private Sub Window2_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
    Dum theGrid = grid
    '...
End Sub

If you try to create another instance, you should use the correct typename:

Dim gridControl As Syncfusion.Windows.Controls.Grid.GridControl
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.