Click here to Skip to main content
15,885,546 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Access to the path 'Global\.net clr networking' is denied Pin
Anubhava Dimri12-Jul-09 18:10
Anubhava Dimri12-Jul-09 18:10 
QuestionI want to click a link in the web page [modified] Pin
pobre1210-Jul-09 23:25
pobre1210-Jul-09 23:25 
Questionsomething like windows vista sidebar or google sidebar Pin
Ali Hojjati10-Jul-09 21:15
Ali Hojjati10-Jul-09 21:15 
AnswerRe: something like windows vista sidebar or google sidebar Pin
Henry Minute11-Jul-09 0:44
Henry Minute11-Jul-09 0:44 
QuestionCan't get combo box to update with data [modified] Pin
Dominick Marciano10-Jul-09 8:01
professionalDominick Marciano10-Jul-09 8:01 
AnswerRe: Can't get combo box to update with data Pin
Henry Minute10-Jul-09 10:45
Henry Minute10-Jul-09 10:45 
QuestionRe: Can't get combo box to update with data Pin
Dominick Marciano16-Jul-09 7:18
professionalDominick Marciano16-Jul-09 7:18 
AnswerRe: Can't get combo box to update with data Pin
Henry Minute17-Jul-09 0:03
Henry Minute17-Jul-09 0:03 
I have used the code that you originally posted to create a project. I did not alter any of your code and I put the methods on the forms that you said they belong to. Obviously I had to make some assumptions about how you did things like loading frmStructures and filling its components with data.

When I ran it I had no problems. I could add new structures and they appeared in frmMain after I clicked 'Done'. So I am not able to help with your problem in that regard.

However, I do have some suggestions, which I hope will help generally.

Your Component Structure:

1) I would suggest renaming this. .NET already has a Component class, and whilst it is not a problem at the moment, the name conflict could well bite you in the bum later.
2) For reasons that are in the next bit, I would suggest modifying it slightly:
Public Structure Component
	Dim ComponentStructure As String
	Dim ComponentMember As String
	Public Overrides Function ToString() As String
		Return Me.ComponentStructure
	End Function
End Structure


Your ReloadCustoms() method:
I would suggest modifying it to be something like:
Public Sub ReLoadCustoms()
    Dim fs As FileStream
    Dim Reader As StreamReader
    Dim div() As String

    fs = New FileStream(AppPath & "\" & StructureFile, FileMode.Open, FileAccess.Read, FileShare.None)

    'Clear Component Array
    ComponentArray.Clear()

    'Check if the file is empty
    If Not fs.Length = 0 Then
        'Create a new stream reader
        Reader = New StreamReader(fs)

        'Read each line of the file until the end of the file
        Do Until Reader.EndOfStream
            'Split each line delimited with '='
            '(Structure=Member1,Member2,...,MemberN)
            div = Reader.ReadLine.Split("=")
            CurrentComponent.ComponentStructure = div(0)
            CurrentComponent.ComponentMember = div(1)
            'Save the component in the 'ComponentArray' array list
            ComponentArray.Add(CurrentComponent)
        Loop
        'Close the stream reader
        Reader.Close()
        'Close the file stream
        fs.Close()
    End If

    cboStructures.Items.Clear()

    For i As Integer = 0 To ComponentArray.Count - 1
                    ' <===================================================>
                    ' <=== This is why the 'Component' structure was modified
                    ' <=== The new ToString() method allows you to add the whole
                    ' <=== structure to the combo, instead of just the 'ComponentStructure' string
                    ' <===================================================>
        Me.cboStructures.Items.Add(ComponentArray(i))
    Next

    cboStructures.Items.Add("...Add...")
    cboStructures.SelectedIndex = 0

                    ' <===================================================>
                    ' <=== Loading cboMembers is not necessary here. That happens
                    ' <=== in the SelectedIndexChanged handler for cboStructures (below)
                    ' <===================================================>
    cboStructures.Update()


    FL_ADDED_NEW_STRUCTURE = False

End Sub


I have assumed that you handle the SelectedIndexchanged event for cboStructures. Mine looks like this:
Private Sub cboStructures_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboStructures.SelectedIndexChanged
    If cboStructures.SelectedItem.ToString = "...Add..." Then
        ' <===================================================>
        ' <==== Your code for loading frmStructures
        ' <===================================================>
    Else
        ' <===================================================>
        ' <==== because the whole 'Component' structure is in cboStructures
        ' <==== we can get at 'ComponentMember' easily to fill cboMembers
        ' <===================================================>
        cboMembers.Items.Clear()
        Dim comp As Component = CType(cboStructures.SelectedItem, Component)
        Dim div As String() = comp.ComponentMember.Split(",")
        cboMembers.Items.AddRange(div)

        cboMembers.SelectedIndex = 0
    End If
End Sub


Even though I was unable to replicate your problem, I hope these suggestions will be of some help to you.

Good Luck! Smile | :)

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

QuestionPrinting in .net Pin
No-e10-Jul-09 7:55
No-e10-Jul-09 7:55 
AnswerRe: Printing in .net Pin
Henry Minute10-Jul-09 11:16
Henry Minute10-Jul-09 11:16 
GeneralRe: Printing in .net Pin
No-e10-Jul-09 11:45
No-e10-Jul-09 11:45 
QuestionFind a 16bit Process Pin
nlarson1110-Jul-09 4:01
nlarson1110-Jul-09 4:01 
AnswerRe: Find a 16bit Process Pin
Dave Kreskowiak10-Jul-09 9:47
mveDave Kreskowiak10-Jul-09 9:47 
GeneralRe: Find a 16bit Process Pin
nlarson1110-Jul-09 9:55
nlarson1110-Jul-09 9:55 
QuestionGoogle Earth in Web Application with adress search capabilities Pin
Member 442053410-Jul-09 3:38
Member 442053410-Jul-09 3:38 
AnswerRe: Google Earth in Web Application with adress search capabilities Pin
DoctorMick10-Jul-09 4:55
DoctorMick10-Jul-09 4:55 
AnswerRe: Google Earth in Web Application with adress search capabilities Pin
DoctorMick10-Jul-09 5:03
DoctorMick10-Jul-09 5:03 
QuestionHow to convert number to indian rupees format text in crystal report??? Pin
JC.KaNNaN9-Jul-09 21:25
JC.KaNNaN9-Jul-09 21:25 
AnswerRe: How to convert number to indian rupees format text in crystal report??? Pin
Nagy Vilmos9-Jul-09 21:58
professionalNagy Vilmos9-Jul-09 21:58 
GeneralRe: How to convert number to indian rupees format text in crystal report??? Pin
JC.KaNNaN9-Jul-09 22:15
JC.KaNNaN9-Jul-09 22:15 
GeneralRe: How to convert number to indian rupees format text in crystal report??? Pin
Nagy Vilmos10-Jul-09 1:03
professionalNagy Vilmos10-Jul-09 1:03 
QuestionMoves data From Program Files in VISTA Pin
Anubhava Dimri9-Jul-09 21:14
Anubhava Dimri9-Jul-09 21:14 
AnswerRe: Moves data From Program Files in VISTA Pin
Dave Kreskowiak10-Jul-09 3:11
mveDave Kreskowiak10-Jul-09 3:11 
GeneralRe: Moves data From Program Files in VISTA Pin
Anubhava Dimri10-Jul-09 18:16
Anubhava Dimri10-Jul-09 18:16 
GeneralRe: Moves data From Program Files in VISTA Pin
Dave Kreskowiak11-Jul-09 18:29
mveDave Kreskowiak11-Jul-09 18:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.