Solved

The GridLineDataGridView learning curve... Part 3

Posted on 2008-06-24
2
248 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

22 Experts available now in Live!

Get 1:1 Help Now