• 0

Show text readme with choice from listbox


Question

Im self educated on visual basic programming. so its basically a learning curve.

 

but need help with something.

 

 

using visual studio 2013 with visual basic net

 

working on map loader for a pc game.

 

there is a txt file with credits and info in the same directory as the maps.

 

so far I have a listbox that scans the directory and shows all the map files and then user selects the map and then clicks a start button and it loads the game with the map. 

 

but I also want to a have a txt box for the map selected showing the information for the map.

 

so what I want to do is when a user clicks on a map in the listbox,it will show a preview of the maps txt file in a separate box on the form.

6 answers to this question

Recommended Posts

  • 0

If your description files have the same name as the maps other than the extension you could just use System.IO.Path.ChangeExtension to create the file name of the text object then load it with File.ReadAllText

 

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        If ListBox1.SelectedItem IsNot Nothing And TypeOf ListBox1.SelectedItem Is String Then
            Dim selectedMap As Object = ListBox1.SelectedItem
            Dim mapDescriptionFile As String = Path.ChangeExtension(selectedMap, "txt")
            If File.Exists(mapDescriptionFile) Then
                TextBox1.Text = File.ReadAllText(mapDescriptionFile)
            End If
        End If
    End Sub
If they're not the same you can either build a dictionary with the map filename as the key and description filename as the value. Or if you want to be lazy you can use a ListView instead and set the Tag property to the description filename. :)

 

    Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems IsNot Nothing And TypeOf ListView1.SelectedItems(0).Tag Is String Then
            Dim selectedMap As ListViewItem = ListView1.SelectedItems(0)
            Dim mapDescriptionFile As String = selectedMap.Tag

            If File.Exists(mapDescriptionFile) Then
                TextBox1.Text = File.ReadAllText(mapDescriptionFile)
            End If
        End If
    End Sub
(The second example assumes that you have set the ListView's MultiSelect property to False since you would only want to display the description for one map at a time.)
  • 0
  On 30/07/2014 at 03:28, dsbig said:

Im self educated on visual basic programming. so its basically a learning curve.

 

but need help with something.

 

 

using visual studio 2013 with visual basic net

 

working on map loader for a pc game.

 

there is a txt file with credits and info in the same directory as the maps.

 

so far I have a listbox that scans the directory and shows all the map files and then user selects the map and then clicks a start button and it loads the game with the map. 

 

but I also want to a have a txt box for the map selected showing the information for the map.

 

so what I want to do is when a user clicks on a map in the listbox,it will show a preview of the maps txt file in a separate box on the form.

 

Hi,

 

I am trying to help you as much as I can but from the looks of your program you want to show a preview of the map, correct? Are you trying to show a Picture of your map or anything else?

 

Normally, you would use the Drawing class to display images on a container or a datagrid. Quickest way would be to add a .NET label on your application, and when the user selects a map you fire an event to load a .bmp file from a specific location.

 

Private Sub CreateMyLabel()

    ' Create a new label and bitmap. 

    Dim Label1 As New Label()
    Dim Image1 As Image

    Image1 = Image.FromFile("c:\\MyImage.bmp")


    ' Set the size of the label to accommodate the bitmap size.

    Label1.Size = Image1.Size        

    ' Initialize the label control's Image property.

    Label1.Image = Image1

    ' ...Code to add the control to the form... 

End Sub
  • 0

I have a listbox  that scans a folder for *.map files and shows a list of maps in the listbox.

 

and there is also a txt file that has credit and also information that folder.

 

when clicking a map title in the listbox. a textbox will show the information for that map.

 

 

list of maps

 

listbox_zps008f2eea.png

 

when someone select a map then it would show the matching .txt file with the information in a box like this. 

 

mapread_zps14dfd2b8.png

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • AS data is written to 1 disk its also written to the other disk in the raid pool. RAID - Wikipedia
    • Its still there, but annoyingly you have to left click the word now and not right click as many millions of peoples muscle memory are quickly finding out.
    • Their initial offerings (AV) were fine, but then there was just absolute stagnation and they had no idea what to do with themselves so they created solutions to problems that really didn't exist, convinced users they did but then realised nobody was buying into it, so bundled their bloated crap with OEM builds. Arguably, the whole AV market got a bad name with end consumers for a period because of companies such as Norton.
    • Windows Server 2025 security baseline to get more frequent updates, streamlines settings by Paul Hill Microsoft has announced the release of the June 2025 revision of its security baseline package for Windows Server 2025 (v2506), it is now available to download from the Microsoft Security Compliance Toolkit. After downloading it, you can test the recommended configurations in your environment and customize or implement them as you see fit. To deal with the evolving threat landscape, new Windows features, and community feedback, Microsoft is planning to revise the Windows Server baseline more frequently in the future. Windows Server security baselines are a collection of Microsoft-recommended configuration settings that help administrators establish secure and consistent Windows Server environments. This is the first security baseline update for Windows Server 2025 since January, a summary of the changes is presented in this table: Security Policy Change Summary Deny log on through Remote Desktop Services Allow remote logon for non-admin local accounts on MS and add “BUILTIN\Guests” to both DC and MS. WDigest Authentication Remove from the baseline Allow Windows Ink Workspace Remove from the baseline Audit Authorization Policy Change Set to “Success” in both DC and MS Include command line in process creation events Enable in both DC and MS Control whether exclusions are visible to local users Moved to Not Configured as it is overridden by the parent setting. Of these changes, the removal of WDigest Authentication and the addition of Include command line in process creation events are significant. Microsoft said it removed WDigest Authentication from the security baseline because it is no longer necessary for Windows Server 2025. The policy was originally enforced so that WDigest couldn’t store plaintext passwords in memory, which was a significant theft risk. Since the 24H2 update in Windows Server 2022, the policy has been deprecated, so there’s no need to enforce this setting. The update also adds Include command line in process creation events to improve the visibility of how processes are executed across the system. By capturing the command-line arguments, it makes it easier to detect and investigate malicious activity that may otherwise seem legitimate. If you want to learn more about the other changes in a bit more depth, refer to Microsoft’s announcement of this security baseline update.
  • Recent Achievements

    • One Month Later
      Leonard grant earned a badge
      One Month Later
    • Week One Done
      pcdoctorsnet earned a badge
      Week One Done
    • Rising Star
      Phillip0web went up a rank
      Rising Star
    • One Month Later
      Epaminombas earned a badge
      One Month Later
    • One Year In
      Bert Fershner earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      537
    2. 2
      ATLien_0
      205
    3. 3
      +FloatingFatMan
      167
    4. 4
      Michael Scrip
      151
    5. 5
      Som
      127
  • Tell a friend

    Love Neowin? Tell a friend!