Click here to Skip to main content
15,035,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have list bound datagrid called Dgv1 ,I use CanUserAddRows="False", I want to add a row in a button click on certain condition. I want to add manually only , not automatically.

Dim _customers = New List(Of Customer)
Dgv1.ItemsSource = _customers

Like this one


this shows error.

Updated 15-May-20 20:24pm

This answer[^] should help you.
<datagrid x:name="grid_bars" horizontalalignment="Left" margin="10,10,0,0" verticalalignment="Top" itemssource="{Binding GridCollection}" canuseraddrows="True" autogeneratecolumns="False">

Then In Code:

public ObservableCollection<grid> GridCollection { get; set; }

Define It in
DataContext = this;
GridCollection = new ObservableCollection<grid>();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900