Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- default badges list -->
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/176968018/19.1.2%2B)
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T830446)
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
<!-- default badges end -->
Expand Down
24 changes: 24 additions & 0 deletions VB/AddRemoveRows.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AddRemoveRows", "AddRemoveRows\AddRemoveRows.vbproj", "{4F666629-A1BE-4D1C-B533-079FB01E98C0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4F666629-A1BE-4D1C-B533-079FB01E98C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F666629-A1BE-4D1C-B533-079FB01E98C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F666629-A1BE-4D1C-B533-079FB01E98C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F666629-A1BE-4D1C-B533-079FB01E98C0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {67EF888A-2C22-4819-8F59-FBBA33DBA461}
EndGlobalSection
EndGlobal
65 changes: 65 additions & 0 deletions VB/AddRemoveRows/AddRemoveRowBehavior.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.UI.Interactivity
Imports DevExpress.Xpf.Grid
Imports System.Windows
Imports System.Windows.Input

Namespace AddRemoveRows

Public Class AddRemoveRowBehavior
Inherits Behavior(Of TableView)

Public Shared AddCommandPropertyKey As DependencyPropertyKey = DependencyProperty.RegisterReadOnly(NameOf(AddRemoveRowBehavior.AddCommand), GetType(ICommand), GetType(AddRemoveRowBehavior), New PropertyMetadata(CType(Nothing, PropertyChangedCallback)))

Public Shared AddCommandProperty As DependencyProperty

Public Property AddCommand As ICommand
Get
Return CType(GetValue(AddCommandProperty), ICommand)
End Get

Private Set(ByVal value As ICommand)
SetValue(AddCommandPropertyKey, value)
End Set
End Property

Public Shared DeleteCommandPropertyKey As DependencyPropertyKey = DependencyProperty.RegisterReadOnly(NameOf(AddRemoveRowBehavior.DeleteCommand), GetType(ICommand), GetType(AddRemoveRowBehavior), New PropertyMetadata(CType(Nothing, PropertyChangedCallback)))

Public Shared DeleteCommandProperty As DependencyProperty

Public Property DeleteCommand As ICommand
Get
Return CType(GetValue(DeleteCommandProperty), ICommand)
End Get

Private Set(ByVal value As ICommand)
SetValue(DeleteCommandPropertyKey, value)
End Set
End Property

Public Sub New()
AddCommand = New DelegateCommand(AddressOf AddNewRow)
DeleteCommand = New DelegateCommand(AddressOf DeleteRow)
End Sub

Protected Overrides Sub OnAttached()
MyBase.OnAttached()
AssociatedObject.InitNewRow += AddressOf OnInitNewRow
End Sub

Private Sub AddNewRow()
AssociatedObject.AddNewRow()
End Sub

Private Sub OnInitNewRow(ByVal sender As Object, ByVal e As InitNewRowEventArgs)
AssociatedObject.Grid.SetCellValue(GridControl.NewItemRowHandle, AssociatedObject.Grid.Columns("ProductName"), "New Product")
AssociatedObject.Grid.SetCellValue(GridControl.NewItemRowHandle, AssociatedObject.Grid.Columns("UnitPrice"), 10)
AssociatedObject.Grid.SetCellValue(GridControl.NewItemRowHandle, AssociatedObject.Grid.Columns("CompanyName"), "New Company")
AssociatedObject.Grid.SetCellValue(GridControl.NewItemRowHandle, AssociatedObject.Grid.Columns("Discontinued"), False)
End Sub

Private Sub DeleteRow()
AssociatedObject.DeleteRow(AssociatedObject.FocusedRowHandle)
End Sub
End Class
End Namespace
108 changes: 108 additions & 0 deletions VB/AddRemoveRows/AddRemoveRows.vbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<OptionInfer>On</OptionInfer>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4F666629-A1BE-4D1C-B533-079FB01E98C0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>
</RootNamespace>
<AssemblyName>AddRemoveRows</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG,TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="DevExpress.Printing.v19.1.Core" />
<Reference Include="DevExpress.Data.v19.1" />
<Reference Include="DevExpress.Data.Desktop.v19.1" />
<Reference Include="DevExpress.Mvvm.v19.1" />
<Reference Include="DevExpress.Xpf.Core.v19.1" />
<Reference Include="DevExpress.Xpf.Printing.v19.1" />
<Reference Include="DevExpress.Xpf.Grid.v19.1.Core" />
<Reference Include="DevExpress.Xpf.Grid.v19.1" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AddRemoveRowBehavior.vb" />
<Compile Include="App.xaml.vb">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainViewModel.vb" />
<Compile Include="MainWindow.xaml.vb">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.vb">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>AddRemoveRows.Properties</CustomToolNamespace>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
9 changes: 9 additions & 0 deletions VB/AddRemoveRows/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="AddRemoveRows.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AddRemoveRows"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions VB/AddRemoveRows/App.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Imports System.Windows

Namespace AddRemoveRows

''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Public Partial Class App
Inherits Application

End Class
End Namespace
53 changes: 53 additions & 0 deletions VB/AddRemoveRows/MainViewModel.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Imports DevExpress.Mvvm
Imports System.Collections.Generic
Imports System.Collections.ObjectModel

Namespace AddRemoveRows

Public Class Person

Public Property ProductName As String

Public Property CompanyName As String

Public Property UnitPrice As Integer

Public Property Discontinued As Boolean

Public Sub New()
End Sub

Public Sub New(ByVal i As Integer)
ProductName = "ProductName" & i
CompanyName = "CompanyName" & i
UnitPrice = i
Discontinued = i Mod 2 = 0
End Sub
End Class

Public Class MainViewModel
Inherits ViewModelBase

Private Shared _Persons As ObservableCollection(Of AddRemoveRows.Person)

Public Shared Property Persons As ObservableCollection(Of Person)
Get
Return _Persons
End Get

Private Set(ByVal value As ObservableCollection(Of Person))
_Persons = value
End Set
End Property

Public Sub New()
Persons = New ObservableCollection(Of Person)(GetSource())
End Sub

Private Shared Iterator Function GetSource() As IEnumerable(Of Person)
For i As Integer = 0 To 9 - 1
Yield New Person(i)
Next
End Function
End Class
End Namespace
39 changes: 39 additions & 0 deletions VB/AddRemoveRows/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Window x:Class="AddRemoveRows.MainWindow"
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:AddRemoveRows"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainViewModel />
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

<dxg:GridControl AutoGenerateColumns="AddNew" ItemsSource="{Binding Persons}">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True">
<dxg:TableView.RowCellMenuCustomizations>
<dxb:BarButtonItem Content="Delete" Command="{x:Static dxg:GridCommands.DeleteFocusedRow}" />
</dxg:TableView.RowCellMenuCustomizations>
<dxmvvm:Interaction.Behaviors >
<local:AddRemoveRowBehavior x:Name="behavior" />
</dxmvvm:Interaction.Behaviors>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>

<StackPanel Grid.Column="1">
<Button Command="{Binding AddCommand, ElementName=behavior}" Width="160" Height="50" Margin="10">Add a New Row</Button>
<Button Command="{Binding DeleteCommand, ElementName=behavior}" Width="160" Height="50" Margin="10">Delete the Focused Row</Button>
</StackPanel>
</Grid>
</Window>
15 changes: 15 additions & 0 deletions VB/AddRemoveRows/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Imports DevExpress.Mvvm.UI.Interactivity
Imports DevExpress.Xpf.Grid
Imports System.Windows
Imports System.Windows.Controls

Namespace AddRemoveRows

Public Partial Class MainWindow
Inherits Window

Public Sub New()
InitializeComponent()
End Sub
End Class
End Namespace
44 changes: 44 additions & 0 deletions VB/AddRemoveRows/Properties/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Windows

' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
<Assembly:AssemblyTitle("AddRemoveRows")>
<Assembly:AssemblyDescription("")>
<Assembly:AssemblyConfiguration("")>
<Assembly:AssemblyCompany("")>
<Assembly:AssemblyProduct("AddRemoveRows")>
<Assembly:AssemblyCopyright("Copyright © 2021")>
<Assembly:AssemblyTrademark("")>
<Assembly:AssemblyCulture("")>
' Setting ComVisible to false makes the types in this assembly not visible
' to COM components. If you need to access a type in this assembly from
' COM, set the ComVisible attribute to true on that type.
<Assembly:ComVisible(False)>
'In order to begin building localizable applications, set
'<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
'inside a <PropertyGroup>. For example, if you are using US english
'in your source files, set the <UICulture> to en-US. Then uncomment
'the NeutralResourceLanguage attribute below. Update the "en-US" in
'the line below to match the UICulture setting in the project file.
'[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
'(used if a resource is not found in the page,
' or application resource dictionaries)
'(used if a resource is not found in the page,
' app, or any theme specific resource dictionaries)
<Assembly:ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)> 'where theme specific resource dictionaries are located
'where the generic resource dictionary is located
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' [assembly: AssemblyVersion("1.0.*")]
<Assembly:AssemblyVersion("1.0.0.0")>
<Assembly:AssemblyFileVersion("1.0.0.0")>
Loading