Solved

The GridLineDataGridView learning curve... Part 3

Posted on 2008-06-24
2
250 Views
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...

Regards

Troubled.
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
 
		Try
 
			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
			setRegKey(dirText.Text)
 
		Catch ex As Exception
 
			frStatusText.Text = ex.ToString
 
		End Try
 
		frGrid.Focus()
 
	End Sub

Open in new window

0
Comment
Question by:jerute
2 Comments
 
LVL 14

Expert Comment

by:Dustin Hopkins
ID: 21859559
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
setRegKey(dirText.Text)
frGrid.DataBind()
0
 

Accepted Solution

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
application restarter  - for an exe that hangs 9 27
REXEX help Part 2 2 25
vb.net 1 month apart 11 30
vb.net winforms sizing/resolution? 4 34
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

809 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