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

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

VB.NET
Dgv1.Items.Add(Dgv1.Items())


this shows error.

thanks.
Posted
Updated 15-May-20 20:24pm

This answer[^] should help you.
 
Share this answer
 
<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
InitializeComponent();
DataContext = this;
GridCollection = new ObservableCollection<grid>();
 
Share this answer
 

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