473,388 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Openfile dialogue and datagrid

I have created a datagrid filled with information from the database. When a user clicks on a particular cell (this cell contains drive letter and file name), I would like to be able to open the file. I have the datagrid cell selection code complete however when the openfiledialog appears, the filename showing in the filename box is openfiledialog1. How do I get the filename to be the actual selection from the datagrid cell. See code below:
Expand|Select|Wrap|Line Numbers
  1. 'MessageBox.Show("Row " & e.RowIndex.ToString() & " and column " & e.ColumnIndex.ToString())
  2.         Dim hit As String
  3.         'Dim fileNm As File
  4.  
  5.         Dim m_inputstream As IO.StreamReader
  6.  
  7.         If e.Button = Windows.Forms.MouseButtons.Right AndAlso e.RowIndex >= 0 Then
  8.             DataGridView1.Rows(e.RowIndex).Selected = True
  9.  
  10.             'configure the dialog 
  11.             With OpenFileDialog1
  12.                 .InitialDirectory = "C:"
  13.                 .Filter = "All Files (*.*)|*.*"
  14.                 .CheckFileExists = True
  15.                 TextBox1.Text = (DataGridView1.SelectedCells(0).Value.ToString())
  16.                 hit = TextBox1.Text
  17.                 TextBox1.Text = (DataGridView1.SelectedCells(0).Value.ToString())
  18.                 hit = TextBox1.Text
  19.  
  20.                 'open Dialiog
  21.                 If .ShowDialog = Windows.Forms.DialogResult.OK Then
  22.                     'm_InputStream = CType(OpenFileDialog1.OpenFile(), System.IO.StreamReader)
  23.                     m_inputstream = New System.IO.StreamReader(OpenFileDialog1.OpenFile)
  24.                     If m_inputstream Is Nothing Then
  25.                         Throw New Exception("Error opeing the file")
  26.                     End If
  27.  
  28.                     'OpenFileDialog1.OpenFile.ToString(filNm)
  29.  
  30.  
  31.                 End If
  32.             End With
  33.  
May 9 '07 #1
0 1116

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Schindler | last post by:
I use Windows Forms C# Appl. Here is my code: if(e.Button == MouseButtons.Left) { if(hti.Type == DataGrid.HitTestType.Cell) { int intKontoID = (int)dataGridFiBuKontenplan;
4
by: dave | last post by:
I have an app that uses the OpenFile Dialog class. When I invoke the ShowDialog method, the hourglass appears and just stays. The dialog window never opens. I created a test form with an...
5
by: kevin | last post by:
Hi, Any help with this would be really appreciated! I'm trying to download a file from a remote server. The access permissions is okay but the problem I'm facing is that the file is getting...
1
by: Mr Gordonz | last post by:
Hi All, I am trying to replicate the functionality of the HTML FileField control (<INPUT type="file">). It does everything I need but for one thing: I can't programmatically set the value of...
12
by: Ger | last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job. The dialogue asks the user to enter some data for the job to follow, and after OK,...
44
by: sasan3 | last post by:
Please read below for my collective response to recent posts on this topic. First a repeat of my suggestion: "Anytime you feel you are in a position to answer a question, but don't feel like...
3
by: UltimateNickFury | last post by:
Hello, I am trying to display the "Printer Settings" dialogue in vb.net. I have found the code for performing this in VB6 but am wondering how this is done in vb.net. Thanks.
2
by: asenthil | last post by:
Hai... i'm triying to open a file in read mode using the following method.. HFILE hFile; hFile=OpenFile("D:\ss.doc",lpReOpenBuff,OF_READ); i cant undestand what is the 2nd parameter is... ...
12
by: Donn Ingle | last post by:
Hi, Okay, so I am in the mood to try this: Inform the user about what modules the app requires in a graphical dialogue that can vary depending on what the system already has installed. (It will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.