|
Yes, that was I encountered. shodialog() seems that user must input a file name and then click OK, otherwise, user can only click cancel
|
|
|
|
|
In MSDN forum, it explains that:
the RestoreDirectory property to ensure that the current directory is restored when the dialog box is closed.
But I tried the example code, I can't find the difference between
RestoreDirectory = true or RestoreDirectory = false.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = False
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
myStream = openFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
' Insert code to read the stream here.
End If
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we didn't throw an exception on open.
If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try
End If
End Sub
|
|
|
|
|
The documentation[^] could be worded better. However, I think the issue is that the OpenFileDialog by default remembers the last directory navigated to. If RestoreDirectory is set to true then it restores the previous saved directory. This should be easy to confirm with a test.
Use the best guess
|
|
|
|
|
Yes, it only reopen the last directory navigated to, whether the ResotreDirectory is set to true or false.
Don't know what the RestoreDirecotry property can do.
|
|
|
|
|
You are right; I just tried it and cannot see any difference.
Use the best guess
|
|
|
|
|
|
I don't think that's entirely true.
I think the FileDialogs change the CurrentDirectory when you navigate around the directory tree. They don't remember the last directory navigated to, but rely on the CurrentDirectory to supply it. When you set RestoreDirectory to true, the CurrentDirectory is reset back to what it was when the dialog was Shown.
|
|
|
|
|
Thanks, I'll look at this more closely some time.
Use the best guess
|
|
|
|
|
It's all a bit confusing as RestoreDirectory does not affect the file dialog's initial directory. What RestoreDirectory is restoring is the program's current directory as reported by Environment.CurrentDirectory . If RestoreDirectory is true then Environment.CurrentDirectory is not affected by any browsing undertaken within the file dialogs.
As for the directory where the file dialog opens that depends.
If InitialDirectory is not set then the directory stored in the LastVisitedMRU registry key is used or if that directory is not available then it's the current directory.
For Windows XP LastVisitedMRU is at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU where per application settings are stored. The registry key values contain a pair of null terminated Unicode strings, the first being the application name and the second the last visited directory.
Alan.
|
|
|
|
|
I have run some further tests and cannot find any effect from this setting. I have also reported it to Microsoft.
Use the best guess
|
|
|
|
|
My application is when a user click Read button, then I got one record of data,then I store it in a file.
when a user click Read Continuous button, then I got one record every 200 ms (use timer control), then I should store the record every 200 ms.
Now I plan to add a Record button, the user click it, it will read the status of Read/Read continuous button, then start the saveing task.
Other way to do that, maybe I can use a varialbe = Record button's state. then In read/read continue button event handler, use the record button state to activate/deactivate recording task.
modified 9-Apr-13 21:25pm.
|
|
|
|
|
Don't do this. DOn't rely on the states of controls to control the state of your application. Maintain the state in your own structures seperate from what controls are telling you. This way, you have better control over what's going on in your application without having to deal with the side-effects of control values. For example, checking Control.Visible will change depending on if the user can actually see the control. It may change if the user drags another window over the top of the control in question.
|
|
|
|
|
|
Hi, I want to implement a funciton on a button, like:
click 1, text="aaa";
click 2, text="bbb";
click 3, text="aaa" = click 1;
click 4, text="bbb" = click 2;
that is, the text would flip-flop with the clicking action.
Now I thought a method that I can do this with a variable to represent the status of the button.
Is there other way to do that flip-flop button function?
modified 9-Apr-13 10:53am.
|
|
|
|
|
|
Thanks, could you give me a simple example on how to use the "OnMouseDownClickCount", and "MouseButtonDownHandler"?
I added a button in a form, just want to test these 2 handler, but don't know how can I connect these 2 event handler with a control.
Thanks
|
|
|
|
|
Yes, you are right.
Declare the variable at the "Form" level and you will be able to manipulate the text of the button.
You could do this with a boolean.
Dim butClicked as boolean = False
Inside your button click event.
If (butClicked) then
set text to aaa
else
set text to bbb
butClicked = Not butClicked
|
|
|
|
|
Hi developers .I have some problem in my project which is on employee timein and timeout.when an employee login in the morning my timein button should accept the timein and add it to the database(ms access).when an employee wants to logout in the evening the timein and timeout form should validate the timein field in the database if timein field contains the login time then form button should active as timeout ,but it is not validating in my project so kindly can anyone help me.so here is my code..:
Dim CN As New OleDbConnection(cnString)
CN.Open()
once if the employee login by its e-id and password it shows the e-name,inthe another textbox.so to select the ename i have coded below.
com2 = New OleDbCommand("SELECT ename from Images WHERE eid ='" & txtemid.Text & "' ", CN)
dr = com2.ExecuteReader
While dr.Read
txtename.Text = dr(0)
'Please below given line is to extarct the only current time except date
txttime.Text = Now.ToShortTimeString
"Now here it is validating for timeout "
com3 = New OleDbCommand("Select * from logtime where eid='" & txtemid.Text & "' and timein<>null and timeout=null and present=null ", CN)
dr1 = com3.ExecuteReader
If dr1.Read Then
Button1.Text = "Time Out"
txttimeout.Text = Now.ToShortTimeString
Exit Sub
Else
End If
|
|
|
|
|
Hi guys,
I need to find text with a specific font color and change its color to another one.
This is more or less what I got:
With ActiveDocument.Content.Find
.ClearFormatting
.Text = ""
.Font.Color = RGB(102,102,153)
With .Replacement
.ClearFormatting
.Text = ""
.Font.Color = RGB(80,176,0)
End With
.Execute Replace:=wdReplaceAll
End With
Problem is: this worked in Word 2007, but in Word 2010, the Font.Color property seems to be dropped. I've tried with Font.ColorIndex and Font.ColorIndexBi , but it doesn't do anything. I can only select a few predefined colors (and clearly it doesn't contain the colors I need )
I prefer to avoid looping through every character if possible. Since we're talking about documents that can contain up to 100k words (and more), it wouldn't be really performant, at least not performant enough to use it on let's say 35 docs in batch .
Anybody an idea about how to bypass that palette restriction?
Thanks you guys
modified 10-Apr-13 3:08am.
|
|
|
|
|
The easiest way of deiling with this, is to open a Word 2010 document, start recording a macro. You select the text and change the front color. Stop the macro and look at the code, it should be there
Edit:
It wont work for shapes though
|
|
|
|
|
I'm going to try that Shapes are not an issue (in this case)
And why on earth didn't I think of that
|
|
|
|
|
Hi,
I recorded it and came up with the following code
Selection.Find.ClearFormatting
Selection.Find.Font.color = RGB(102, 102, 153)
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.color = RGB(0, 176, 80)
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Cheers!
|
|
|
|
|
How can i make mp project int .exe file
|
|
|
|
|
What is an "mp project"?
Use the best guess
|
|
|
|
|
I have installed the Crystal report for vs 2010. I want to generate the crystal report for my project. I have written the following code on button click event.
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Dim sqlQRY As String = "SELECT * FROM Customers"
Dim cmdExec As SqlCeCommand = New SqlCeCommand(sqlQRY, conn)
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter(sqlQRY, conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Customers")
Dim Report As frmReports = New frmReports
Dim mReport As rptCustomers = New rptCustomers
mReport.SetDataSource(ds)
Report.CrystalReportViewer1.ReportSource = mReport
Report.ShowDialog()
End Sub
But when i run the program I got the following error. What to do?
"Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified."
|
|
|
|