The GridLineDataGridView learning curve... Part 3

Posted on 2008-06-24
Last Modified: 2013-12-25
Ok, so I have my GridLineDataGridView in place and it displays the data correctly and suitable, TO START WITH.

Then comes the problem. When I change directory and call gridRefresh() to update the dataset and (hopefully) redraw the grid, I get some unpredictable results. The contents of the new directory aren't displayed.

What command should I use to re-draw the grid? I've tried GridLineDataGridView.redraw() but that just generated a null exception error.

ipaulino, if you are reading this...


Public Sub gridRefresh()

		Dim dt As New DataTable()

		dt.Columns.Add("Original Name")

		dt.Columns.Add("New Name")

		Dim pattern As String = patternText.Text

		If pattern.LastIndexOf("(") >= 0 Then

			pattern = pattern.Substring(0, pattern.LastIndexOf("("))

		End If


			Dim dirInfo As New DirectoryInfo(dirText.Text)

			Dim fileInfos() As FileInfo

			Dim fileName As String

			Dim extIndex As Integer

			fileInfos = dirInfo.GetFiles(pattern)

			For Each fileInfo As FileInfo In fileInfos

				extIndex = fileInfo.Name.LastIndexOf(".")

				fileName = fileInfo.Name.Substring(0, extIndex)

				dt.Rows.Add(fileInfo.Name, fileName)

			Next fileInfo

			frGrid.DataSource = dt


		Catch ex As Exception

			frStatusText.Text = ex.ToString

		End Try


	End Sub

Open in new window

Question by:jerute
LVL 14

Expert Comment

by:Dustin Hopkins
Comment Utility
not so sure about gridline, but it doesn't look like you are rebinding the grid after you set the new datasource. Focus, usually doesn't cut it. is there a databind method, or maybe thats what redraw is.

something like:
frGrid.DataSource = dt

Accepted Solution

jerute earned 0 total points
Comment Utility
Finally I've settled on the DataGridView.rows.clear() method followed by a complete refresh. This seems to work ok.

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now