.NET Framework - Cannot clear all rows in datagridview
Asked By Bill Nguyen
21-Mar-07 05:54 PM
I tried almost everything
.Rows.clear()
.rowcount = 0
and the rows in a datagridview still not cleared
I populated the Datagridview manually using Row.Add
Any help is greatly appreciated
Bill
SQL Server
(1)
Compact Framework
(1)
Visual
(1)
EventArgs
(1)
DataTable
(1)
Button
(1)
Update
(1)
Load
(1)
pvdg42 replied...
How do you know that the clear() method is not working?
ClayB replied...
The code below works in a simple form with a DataGridView and Button
dropped on it.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.DataGridView1.ColumnCount = 3
Me.DataGridView1.AllowUserToAddRows = False
Me.DataGridView1.Rows.Add(New String() {"abc", "efg", "hij"})
Me.DataGridView1.Rows.Add(New String() {"111", "efg", "hij"})
Me.DataGridView1.Rows.Add(New String() {"222", "efg", "hij"})
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
'either works
Me.DataGridView1.RowCount = 0
'Me.DataGridView1.Rows.Clear()
End Sub
==========================
Clay Burch
Syncfusion, Inc.
Bill Nguyen replied...

Me.DataGridView1.RowCount = 0
Me.DataGridView1.Rows.Clear()
It didn't work on mine.
Is it a problem with version/SP update?
I'm usign VS 2005. Info as below
Thanks
Bill
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
Microsoft Visual Basic 2005 77626-009-0000007-41468
Microsoft Visual Basic 2005
Microsoft Visual C# 2005 77626-009-0000007-41468
Microsoft Visual C# 2005
Microsoft Visual C++ 2005 77626-009-0000007-41468
Microsoft Visual C++ 2005
Microsoft Visual J# 2005 77626-009-0000007-41468
Microsoft Visual J# 2005
Microsoft Visual Web Developer 2005 77626-009-0000007-41468
Microsoft Visual Web Developer 2005
Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005
Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU
(KB925674)
This Security Update is for Microsoft Visual Studio 2005 Professional
Edition - ENU. \n
If you later install a more recent service pack, this Security Update will
be uninstalled automatically. \n
For more information, visit http://support.microsoft.com/kb/925674
SQL Server Analysis Services
Microsoft SQL Server Analysis Services Designer
Version 9.00.3042.00
SQL Server Integration Services
Microsoft SQL Server Integration Services Designer
Version 9.00.2047.00
SQL Server Reporting Services
Microsoft SQL Server Reporting Services Designers
Version 9.00.2047.00
pvdg42 replied...
I'll try again. How, exactly, do you know that Clear() is not working?
Have you added code to your application to check the remaining contents of
the DataTable within your DataGridView during the same run, or are you
checking your DataSource while in design mode?
Bill Nguyen replied...
I'm not going that far.
The Datagridview was still showing data. I want it to be cleared in my view.
If it cleared but I can still see all the rows and columns on the screen, I
would say that it's not working!
Thanks
Bill
pvdg42 replied...
I would agree :)
Here's an article written on the subject that may be useful:
I guess it depends on how you're populating the DataGridView. If it's bound
to a data source then I would remove the binding; otherwise, if the rows
were added manually then I would just clear the rows collection.
if (this.dataGridView1.DataSource != null)
{
this.dataGridView1.DataSource = null;
}
else
{
this.dataGridView1.Rows.Clear();
}
Does that work in your situation?
--
Tim Wilson
.NET Compact Framework MVP
I realize the code is C#, but the translation should pose no problems. Works
for me.
SQL Server Compact 3.5 breaks VS2008 install .NET Framework I'm trying to do a full installation ever been installed on any of them before. The problem occurs when the component "Microsoft SQL Server Compact for Devices" is being installed. The installtion stops and a popup showing that setup.exe is displayed. The error log shows one single row with the the following error: Microsoft SQL Server Compact 3.5 For Devices: [2] Error: Installation failed for component Microsoft SQL Server Compact
SQL Server Compact .NET Framework Hallo, wenn ich in WebDeveloper2008 Ex. im Datenbank Explorer versuche eine Verbindung zu einer Datenbank herzustellen, wird mir nicht der SQL Server Compact 3.5 angezeigt. In C# 2008 Ex. wird dort der entsprechende Eintrag unter Datenquelle angezeigt Wo kann ich den SQL Server Compact zu den Datenquellen zufügen? Frank ASP.NET - German Discussions SQL Server Compact 3.5
Linq To SQL / SQL Server Compact 3.5 / Installation .NET Framework Hallo , ich stehe vor folgendem Problem: Ich benutze in einer Anwendung den verwalteten SqlCe-Provider (System.Data.SqlCe) sowie auch einen DataContext um mit einer SQL-Server-Compact-DB zu interagieren. Das funktioniert auch prima auf meinem Entwicklungs-PC. Sobald ich jetzt versuche auf dem sich lediglich das .Net-Framework 3.5 sowie die Runtime-DLL's des Sql-Server Compact befinden, mein Programm auszuführen kommt beim instanzieren des DataContextes die Fehlermeldung das der
Merge Replication SQL 2000 and SQL Server Compact .NET Framework I have a desktop application using SQL Server Compact Edition and I want to use merge replication with an SQL Server 2000 database (SP4). I have installed all the necessary things (sqlcesa30.dll is available
Stored Procedures in SQL Server Compact? .NET Framework Hi, sind Stored Procedures im SQL Server Compact möglich? Danke Michael .NET Datenbank - German Discussions SQL Server (1) Vergleich (1) Gruß (1) Möglich (1) Aktuelle (1) Für (1) Sind (1) Hallo