Jump to content
Xtreme .Net Talk

hog

Avatar/Signature
  • Posts

    1011
  • Joined

  • Last visited

Everything posted by hog

  1. The control is on the main form on a tabpage within a panel so I suspect I need to use code to drill down to find it in order to refresh it. I have managed to modify a simply textbox as a test and all worked as expected.
  2. I have this code on the close event of one form gfrmMyForm.lstvPDFFiles.Refresh() The idea is that when the form that this code is in closes the listview control on the from referenced by gfrmMyForm should be refreshed. However it does not? I have also tried using Invalidate() with no joy. Any idea??
  3. Keep a variable that is assigned the tabpage number when it is selected. When and if an error occurs call something like Me.tbcTabControl.SelectedTab = Me.tbpTabPage1 This works fine for me but I also use hashtables to help..
  4. hog

    checkboxes

    Along with using the AutoCheck property set to False I have not placed this code on the Click Event of the CheckBox which resolces the problem.....allbeit messy :( Private Sub chkRemoveP1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkRemoveP1.Click Dim chkCheckBox As CheckBox = DirectCast(sender, CheckBox) If chkCheckBox.Checked Then chkCheckBox.Checked = True End If End Sub
  5. hog

    checkboxes

    LOL:) Ok I have set the AutoCheck property to False which has the following result. When the form opens the user can click the checkbox and no check appears which is what I want. But when the app changes the checkbox to checked and then the user clicks it the check can be removed!! DOH....
  6. I'm sure there must be an easy way but I must be missing it:( How can I make a checkbox read only? I have tried using Enabled=False but this greys out the control. I want the checkbox to remain looking like it does when it is enabled but not allow the user to change it??
  7. hog

    DoEvents problem

    Mmm this appears to solve the problem.... Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed ' create file watcher to check for when the data has been exported from CIRCE-MI Me.FileSystemWatcher6.Path() = Environment.GetFolderPath(Environment.SpecialFolder.Personal) Me.FileSystemWatcher6.Filter = "p1.txt" Me.FileSystemWatcher6.NotifyFilter = NotifyFilters.LastWrite ' create the event handlers for the file watchers and pass the address of the code that should run AddHandler FileSystemWatcher6.Created, AddressOf FileSystemWatcher6_Changed ' start watching Me.FileSystemWatcher6.EnableRaisingEvents = True End Sub Private Sub FileSystemWatcher6_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher6.Changed Dim fwFileWatcher As FileSystemWatcher = DirectCast(sender, FileSystemWatcher) ' call sub to extract PIs from p1.txt and write them to p2.txt If Not GenerateP2Textfile(fwFileWatcher) Then Return End If ' this will only get checked if the p2.txt was created successfully Me.chkP1Detected.Checked = True End Sub the generatep2text file function remains the same without the loop. Therefore running it now does not result in 100% cpu usage:)
  8. I have code running detailed below that uses a FileSystemWatcher to check for the creation of a file which then call the GenerateP2Textfile function. This function uses a loop with a DoEvents call in it and stays in the loop until the file in question has content. The loop exits OK as the rest of the code after the loop runs OK as does the app. However when everything else is all done and dusted the code when I'm stepping through it returns to the DoEvents loop?? Have I missed something?? Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed Dim fwFileWatcher As FileSystemWatcher = DirectCast(sender, FileSystemWatcher) ' call sub to extract PIs from p1.txt and write them to p2.txt If Not GenerateP2Textfile(fwFileWatcher) Then Return End If ' this will only get checked if the p2.txt was created successfully Me.chkP1Detected.Checked = True End Sub Private Function GenerateP2Textfile(ByVal fwFileWatcher As FileSystemWatcher) As Boolean Dim strFileName As String ' get the full path of the p1.txt file strFileName = fwFileWatcher.Path & "\" & fwFileWatcher.Filter ' open a fileinfo object against p1.txt Dim fFileInfo As FileInfo = New FileInfo(strFileName) ' stay in this loop until circe-mi has written data to p1.txt Do Application.DoEvents() Loop Until fFileInfo.Length > 0 Dim srFile1 As StreamReader Dim srFile2 As StreamWriter Dim strDelimiter As String = ControlChars.Tab Dim chrDelimiter As Char() = strDelimiter.ToCharArray() Dim strWords As String Dim strSplit As String() = Nothing Try ' open a stream reader to read p1.txt srFile1 = New StreamReader(strFileName) ' open a stream writer to write to p2.txt srFile2 = New StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\p2.txt", True) Dim intX As Integer ' read in one line at a time strWords = srFile1.ReadLine Do While strWords <> Nothing ' decipher the delimiters used For intX = 1 To 9 strSplit = strWords.Split(chrDelimiter, intX) Next intX ' write the first field out to p2.txt srFile2.WriteLine(strSplit(0)) ' read in the next line strWords = srFile1.ReadLine Loop Return True Catch objException As Exception ShowError("Location: Class frmCIRCEImports" & ControlChars.CrLf & ControlChars.CrLf & _ "Procedure: GenerateP2Textfile(ByVal fwFileWatcher As FileSystemWatcher)" & ControlChars.CrLf & ControlChars.CrLf & "Error Text: " & _ objException.Message) Return False Finally srFile2.Flush() srFile2.Close() End Try End Function
  9. DOH! as easy as that!! I had my code in the SelectedIndexChanged event.... Thnx:)
  10. I think this is possible, and I think I have seen a thread some time ago on this site on how to reference other apps. Try doing a search to see what comes up.
  11. I'm using a listview for the first time. I have two problems: 1. The first is that the control only seems to allow a single click to select an item in the list. Is there no way to change this to a double click? 2. After the first click which accepts the choice being made if I then click on any white area of the control I get an error message "specified argument was out of range of valid values: parameter name index" Any ideas??
  12. hog

    New to Threads

    Ok after reading the tutor corner on this site and followed the links there I have now added this code: Delegate Sub ChangeLoadDelegate() Me.CrystalReportViewer1.Invoke(New ChangeLoadDelegate(AddressOf LoadReport)) But I still get the same error :(
  13. I'm trying to export a report to pdf whilst opening and displaying the report to the user. This is causing a long delay before the user can do anything with the report view. I have had a go at creating threads but get the following error message when I run the code below: "Controls created on one thread cannot be parented to a control on a different thread" Private Sub CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load Try Select Case gintReportType Case gconstReportMailShot myReport = New repMailShot myReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait Case constReturns ' myReport = New repReturns myReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait End Select myReport.SetDataSource(m_dsReportSource) Dim thdCopyPDF As New Thread(AddressOf CopyToPDF) Dim thdLoadReport As New Thread(AddressOf LoadReport) thdLoadReport.Start() thdCopyPDF.Start() Catch objException As Exception ShowError("Location: Class frmReports" & ControlChars.CrLf & ControlChars.CrLf & "Procedure: " & _ "CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs)" & _ ControlChars.CrLf & ControlChars.CrLf & "Error Text: " & objException.Message) End Try End Sub Private Sub CopyToPDF() myReport.ExportToDisk(CrystalDecisions.[shared].ExportFormatType.PortableDocFormat, gstrServerArea & "Mailshot.pdf") End Sub Private Sub LoadReport() Try Me.CrystalReportViewer1.ReportSource = myReport Me.CrystalReportViewer1.Zoom(75) Catch objException As Exception ShowError("Location: Class frmReports" & ControlChars.CrLf & ControlChars.CrLf & "Procedure: " & _ "LoadReport" & ControlChars.CrLf & ControlChars.CrLf & "Error Text: " & objException.Message) End Try End Sub Have I misunderstood thread usage?
  14. hog

    Barcode query

    We currently use some Symbol PDT6800 handsets to scan items into our warehouse which uses MCL as the user interface on the scanner. The rest of the process is interaction between the MCL interface via ODBC to an Access database. I have no knowledge of this or where to look, but does anyone know if it is possible for me to write a VB.NET interface that would run on the handheld instead of MCL? Thanks for any advice.....
  15. Sussed it :) I also have an order line field which when ordered results in: 1 10 2 3 4 etc.... So this is where the problem was and is now sorted....
  16. Upon further checking this problem starts as soon as the record count goes into double figures? So to clarify... If I'm adding record 9 the move to recordcount-1 gives me the ninth (last) record. If I'm adding record 10 the move to recordcount-1 gives me the ninth (last but one) record! Please any help would be most welcome....
  17. I have a database that hase 10 records in it. If I use code like this with intRecordnumber set to 10 I get an error "There is no row at position 10" m_drContract = m_dsContract.Tables("tblContracts").Rows(intRecordNumber) However if I use this code with intRecordNumber set to 9 it returns the actual row at position 9??? I understand the Row is using zero base so if I ask for record 9 I should get the last tenth reord, but I don't I get the ninth? Any ideas??
  18. So does this mean I'm stuffed?
  19. I am stepping through my code to trap where a problem is occuring and all steps though OK but at different areas in my code I get the above message. It is weird as on prvious runs the step works ok but then errors on another section that worked prviously. Does anyone know what this actually means??
  20. Thx Pete.....got it sussed now and the String.split works a treat:)
  21. hog

    why do you find

    divil you are a star.....you just saved my bacon...pardon the pun..oink Thnx:)
  22. the place in your project to modify the version of the app as reported by: System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString I've released a new version but this code is still reporting 1.0 instead of 1.1
  23. Ok this is what I have now but am getting wierd output?? I have a text file with these entries, (any ole guff)... dog cat horse fish Each separated by a tab. This is my code: Dim strDelimiter As String = ControlChars.Tab Dim chrDelimiter As Char() = strDelimiter.ToCharArray() Dim strWords As String = srFile1.ReadLine Dim strSplit As String() = Nothing Dim intX As Integer For intX = 1 To 9 strSplit = strWords.Split(chrDelimiter, intX) Dim strNewString As String For Each strNewString In strSplit MessageBox.Show(strNewString & ControlChars.CrLf) Next strNewString Next intX Problem is this....output of each loop results in: dog cat horse fish dog dog cat horse fish dog cat horse fish dog cat horse fish I know it is to do with the loops and I've tried just getting one string at a time out of the split array with no joy:(
  24. Mmm string.split looks interesting:) I was just working out on using MID() to cycle through.... I'll read on thnx
  25. No the file is like this: dog cat fish horse motorbike Each gap is a tab character. I'm just reading in the online help about random access and creating a random access variable. This might be the answer as if I get the field sizes from the bods that produce the text file I may be in business....I think?
×
×
  • Create New...