Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Martin Smith

@Martin Smith
About
Posts
18
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Rich Text Box Colors? [modified]
    M Martin Smith

    A while back I wrote some software to colour code a report that was displayed in an RTF box. Perhaps it will be of some use to you:

    Private Sub Add_text_to_report(ByVal The_text As String, ByVal Style As System.Drawing.FontStyle, ByVal Colour As System.Drawing.Color)
    Dim Font As New Font(rtBox.Font.FontFamily, rtBox.Font.Size, Style)
    Dim Len As Integer = rtBox.Text.Length()

        ' Add the text
        rtBox.AppendText(The\_text)
    
        ' Now format it as specified
        rtBox.SelectionStart = Len
        rtBox.SelectionLength = The\_text.Length
        rtBox.SelectionFont = Font
        rtBox.SelectionColor = Colour
    
        ' Clear the selection
        rtBox.SelectionStart = 0
    End Sub
    

    Simply add this sub-routine into your form and whenever you want to add text to the RTF Box just call the routine, specifying the string to add, its format (i.e. bold, underline etc, and its colour) Hope this helps, Regards

    Martin

    Visual Basic winforms graphics question announcement

  • disabling right click in web browser
    M Martin Smith

    Assuming it is the Internet Explorer web browser that you have embedded into your form/project, you can disable the right-click context menu by setting the WebBrowser property IsWebBrowserContextMenuEnabled to False. I hope this helps, Regards,

    Martin

    Visual Basic csharp

  • MDI skinning question
    M Martin Smith

    Hi Daniel, I'm not sure it is possible to achieve what it is you are trying do, but I do have a bit of past experience with MDI forms. I originally wrote an application where I wanted to change the backround image of the MDI form. This is not possible by setting the forms "BackgroundImage" property. I found that the MDI form has a control on it that handles all the displaying of child forms. It is this control that I had to alter the background image property of. Below is a snippet of code I used to achieve this, perhaps you can manipulate the MDI form control in a similar fashion to what I did to achieve your rounded corners:

        For Each Mdi\_display As Control In Me.Controls
            If TypeOf (Mdi\_display) Is MdiClient Then
                ' Set colour to white
                Mdi\_display.BackColor = Color.White
    
                ' Centre the image
                Mdi\_display.BackgroundImageLayout = ImageLayout.Center
    
                ' Set background image
                Mdi\_display.BackgroundImage = My.Resources.Main\_background
    
                Mdi\_display.Refresh()
    
                ' All done!
                Exit For
            End If
        Next
    

    Regards,

    Martin

    Visual Basic graphics question

  • VB2005 documentation generator
    M Martin Smith

    You might want to take a look at the VSdocman 3.0 addin for Visual Studio. It parses your source code and generates MSDN style documentation, that is completely customisable.... There web address is: www.helixsoft.com[^] Regards,

    Martin

    Visual Basic question

  • Reading XML
    M Martin Smith

    It would seem there is a problem with your XML data and not your programming. The Root Node from your XML data is missing -- what is your XML data?? Martin

    Visual Basic xml help tutorial

  • Problem
    M Martin Smith

    As already mentioned there is no line in bold, but looking at the code you have supplied there seems to be an end sub that is in error/not required. My guess at this point in time is to delete the end sub at the bottom of your ReadOnly property. Regards, Martin

    Visual Basic help

  • intptr in vb.net
    M Martin Smith

    It is best to only use types such as int32, int16 etc. when you need to guarentee a certain number of bits are used to store a value (whether that be numerical, bit flags, or just encoded data of a proprietory type). If you generally dont care how many bits it takes to store the value use a basic type, such as integer, long etc. The general purpose, from my point of view, for types such as int32 is to ensure portability of code across several platforms (as I mention above e.g. -- if you are using the bits in a variable to flag information you may need to ensure you have a minimum of 32 bits -- using a basic type like integer does not mean you will necessarily have a 32bit variable, although in the case of .Net this is actually true). Regards, Martin

    Visual Basic csharp

  • Reading XML
    M Martin Smith

    Its hard to give an example without knowing what the XML data is, that said, below is an example that will create an x-path navigator for XML data taken from a string variable:

    Dim sReader As New IO.StringReader(My\_XML\_Text\_string)
    Dim xDoc As New Xml.XPath.XPathDocument(sReader)
    Dim xNav As Xml.XPath.XPathNavigator = xDoc.CreateNavigator()
    

    The variable My_XML_Text_string contains your XML data.... At this point you can navigate through the XML nodes and attributes using the xNav instance Regards, Martin

    Visual Basic xml help tutorial

  • Form resize issue
    M Martin Smith

    Hi, The TableLayoutPanel (I'm using VS2005 Pro, so I've assumed you are using it too, and hoping you have access to this form control!!) is in the "Toolbox" (i.e. where you find labels and textboxes and the like) under the "Containers" section. It works like a spreadsheet with rows and columns. What you need to do is dock your controls within the TableLayoutPanels cells (its obvious once youve dragged one onto your form).... Also reading this thread, Are some problems related to the size of the operating system font (i.e. Display Settings->Advanced === By default this will be "Normal". Perhaps your friends PC is set to Large or Extra Large) Regards, Martin

    Visual Basic help question

  • Form resize issue
    M Martin Smith

    Add a TableLayoutPanel to your form (Dock style: Fill) and then add your original controls to this. You will need to add rows and columns accordingly to accomodate everything but windows will ensure everything is correctly resized when your form changes at runtime. Regards Martin

    Visual Basic help question

  • Array Conversion vb 6 syntax not working with .net
    M Martin Smith

    Instead of Redim Preserve you could use Array.Resize(marr, count) Regards, Martin

    Visual Basic help csharp data-structures tutorial

  • Card Game ?
    M Martin Smith

    In your FOR loop that is creating the labels, add an event handling function for the mouse click event, for example: AddHandler Label(N).MouseClick, AddressOf CardClickFct You will then need to create the CardClickFct, such as: Sub CardClickFct(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim TheCard as label = DirectCast(sender, Label) ' TODO: Add whatever you want the card to do when its been clicked End Sub What you must also remember to do is remove the event handler when the label is destroyed (by calling RemoveHandler).... You MUST ensure that your array variable "Label" is declared "WithEvents" for this to work!!! I hope this helps you out.... Regards, Martin

    Visual Basic game-dev data-structures help tutorial question

  • Append text file
    M Martin Smith

    I guess it will all depend on the size of the input file.... Perhaps a tweak to the "while" loop inside your cleanFile() function may help speed things up: Private Sub CleanFile() 'Read file line by line Dim file_name As String = "c:\Scanning files\lsprint_MO.txt" Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName Dim textline As String If System.IO.File.Exists(file_name) = True Then Dim objReader As New System.IO.StreamReader(file_name) Do textline = String.Concat(objReader.ReadLine(), ControlChars.NewLine) If textline.IndexOf("xxxxxxx") = 17 Then WriteFile(Temp_file, textline) Loop Until textline Is Nothing objReader.Close() My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt") My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt") End If End Sub Other than that, I'm affraid I have no ideas..... Regards, Martin

    Visual Basic help

  • control resetting
    M Martin Smith

    Add the following to your Reset Button click event and it should sort out your issue: For Each Ctl As Control In Me.Controls If TypeOf Ctl Is TextBox Then Ctl.Text = String.Empty Next Regards, Martin

    Visual Basic question csharp

  • Command prompt (cmd.exe) as a hidden process
    M Martin Smith

    Thanks a lot for having a look into my problem Dave, You have provided a brilliant analysis, and I guess its a limitation I am going to have to live with.... Best regards, Martin

    Visual Basic csharp design tutorial question

  • Append text file
    M Martin Smith

    I notice you have got the parameters the wrong way round in your call to the WriteFile() function.... You are basically on the right track: Here is my (slightly corrected) version of your WriteFile() function: Private Sub WriteFile(ByVal Output_file as string, ByVal The_text as String) Dim oWrite As System.IO.StreamWriter If File.Exists(Output_file) = False Then ' Create a new file to write to. oWrite = IO.File.CreateText(Output_file) Else ' Append to file oWrite = IO.File.AppendText(Output_file) End If oWrite.WriteLine(The_text) oWrite.Flush() oWrite.Close() End Sub And here is my version of your CleanFile() Function: Private Sub CleanFile() 'Read file line by line Dim file_name As String = "c:\Scanning files\lsprint_MO.txt" Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName Dim textline As String If System.IO.File.Exists(file_name) = True Then Dim objReader As New System.IO.StreamReader(file_name) Do While objReader.Peek() - 1 textline = objReader.ReadLine() & vbNewLine If textline.IndexOf("xxxxxxx") = 17 Then 'Console.WriteLine(textline) WriteFile(Temp_file, textline) End If Loop objReader.Close() My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt") My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt") End If End Sub One thing to note here, your original lsprint_MO.txt file will be overwritten by the process of running CleanFile().... I hope this clears everything up for you.... Have fun and best regards, Martin

    Visual Basic help

  • Append text file
    M Martin Smith

    Hi, You are seeing this problem because the WriteFile() function is trying to open a stream to the same file opened in the CleanFile() function. A quick and easy solution is to create a temporary output file and pass its filename into the WriteFile() function, then at the end of the CleanFile() function delete the original c:\Scanning files\lsprint_MO.txt file and then rename the temporary file... You can get a temporary file name by: dim Temp_file as String = my.Computer.FileSystem.GetTempFileName() Then update WriteFile() function: Private Sub WriteFile(ByVal OUTPUT_FILE as String, ByVal fname As String) Dim oWrite As New System.IO.StreamWriter(OUTPUT_FILE) oWrite = IO.File.AppendText(fname) End Sub At the end of CleanFile() ObjReader.Close() My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt") My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt") I hope this helps you out.... Regards Martin

    Visual Basic help

  • Command prompt (cmd.exe) as a hidden process
    M Martin Smith

    Hi all, I am writing a VB.Net application that has a Command Prompt, which is running as a hidden process and I am redirecting the standard input/output from this process to my own user interface. Everything seems to be working fine for regular DOS commands, for example; If I type "DIR" into my user-interface it displays exactly the same as if I'd typed DIR in to a command prompt window -- no problems there.... If I enter the name of an executable that is a windows based application, for example notepad.exe, then nothing seems to happen. If I then close my application the program I tried to start (i.e. Notepad) magically appears. Having delved a bit deeper into this, I notice that after executing the notepad.exe command in my user interface, task manager is showing a "notepad.exe" process running but its not visible. I tried executing the dos command "start notepad.exe", and hey presto - the Notepad application starts up and is immediately visible. Does anybody have any ideas as to why my hidden command prompt process is not making windows based applications immediately visible (unless they are proceeded by the "start" command)?? Thanks, Martin

    Visual Basic csharp design tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups