Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, February 22, 2014 1:05 PM
I'm using C# 2010 Express to do some testing before moving MS Access applications to Visual Studio
When I reference a datagridview in my code
DataGridView1.Rows.Add();
I get a Namespace error, specifically:
'System.Windows.Controls.DataGrid' does not contain a
definition for 'Rows' and no extension method 'Rows' accepting a first argument
of type 'System.Windows.Controls.DataGrid' could be found (are you missing a
using directive or an assembly reference?)
And when I go to add the appropriate assembly reference, it isn't allowed. If I simply add the following line:
using System.Windows.Controls.DataGrid /// I already have a reference - using System.Windows.Controls
I get the following message.
A using namespace directive can only be applied to namespaces; 'System.Windows.Controls.DataGrid' is a type not a namespace
_____________________________
When I then go to references, right-click, choose Add References, choose .NET, there is no reference object
System.Windows.DataGrid;
How do I get System.Windows.DataGrid; added to my assembly references?
Thanks in Advance - Pavilion
All replies (2)
Saturday, February 22, 2014 2:07 PM ✅Answered
System.Windows.DataGrid does not have property Rows so you can't write this lineDataGridView1.Rows.Add();
you can use DataGridView1.ItemsAdd You can refer this link for more infomation on datagrid.
http://msdn.microsoft.com/en-us/library/vstudio/system.windows.controls.datagrid(v=vs.100).aspx
Ashish Pandey
Saturday, February 22, 2014 5:12 PM ✅Answered
You may be confusing Windows Forms and WPF. DataGridView is a Windows Forms control and DataGrid is a WPF control.
Windows Forms is in the namespace System.Windows.Forms
WPF is in the namespace System.Windows and System.Windows.Controls
~~Bonnie DeWitt [C# MVP]