TextBox and Postion Changed

  • Thread starter Thread starter MadCrazyNewbie
  • Start date Start date
M

MadCrazyNewbie

Hey Group,

I have the following code listed below:

On my Winform I have 3 List Box`s and a Text Box. When I click on Catagories
on my first ListBox it lists the Sub Catagories for that in the Second, when
I click on a Sub Catagorie, it lists all my Documents for that in the Third
List box.

My Text Box Lists the Patch of the Document which I get from my Database.

However ......... My Textbox dosn`t refresh, i mean as in, when i click on
any document, in any sub catagorie the textbox only lists the first one i
clicked on:(

I was think i may need something similar to Selected_IndexChange but i don`t
quite know what.

Any help much appriciated.

Many Thanks
Regards
Si
Dim dvCatagory As DataView
Dim dvDocuments As DataView
Private Sub frmTechDocs_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
odcTechDocs.ConnectionString = Connection.String

mlLoading = True
'Start of Fill Datasets
Try
dsTechDocs.EnforceConstraints = False
Try
Me.odcTechDocs.Open()
'Fill Documents Datasets
Me.odaCatagories.Fill(dsTechDocs)
Me.odaSubDocuments.Fill(dsTechDocs)
Me.odaDocuments.Fill(dsTechDocs)
Me.lstCatagories.DataSource = dsTechDocs.DocumentCatagories
Me.lstCatagories.DisplayMember = "DocumentCatagories"
Me.lstCatagories.ValueMember = "DocumentCatagoriesID"
dvCatagory = New DataView(dsTechDocs.DocumentSubCategories)
Me.lstSubCatagories.DataSource = dvCatagory
Me.lstSubCatagories.DisplayMember = "DocumentSubCatagories"
Me.lstSubCatagories.ValueMember = "DocumentSubCatagoriesID"
' dvCatagory.RowFilter = "DocumentCatagories = ' '"
dvDocuments = New DataView(dsTechDocs.Documents)
Me.lstDocuments.DataSource = dvDocuments
Me.lstDocuments.DisplayMember = "DocumentName"
Me.lstDocuments.ValueMember = "DocumentLocation"
dvDocuments.RowFilter = "DocumentSubCatagories = ' '"
Catch fillException As System.Exception
Throw fillException
Finally
'To be enabled if Dataset Bindings Fail - Enabling will
cause BIG Datasets
'dsDocuments.EnforceConstraints = True
Me.odcTechDocs.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

Private Sub lstCatagories_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstCatagories.SelectedIndexChanged
If mlLoading = False Then
Dim a As String = lstCatagories.SelectedValue.ToString
Dim b As String = dvCatagory(0)("DocumentCatagories").ToString

dvCatagory.RowFilter = "DocumentCatagories = '" &
lstCatagories.SelectedValue.ToString & "'"
End If
End Sub

Private Sub lstSubCatagories_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstSubCatagories.SelectedIndexChanged
If mlLoading = False Then
dvDocuments.RowFilter = "DocumentSubCatagories = '" &
lstSubCatagories.SelectedValue.ToString & "'"
End If
End Sub
 
Simon,

In the code is not the lstDocumentSelected Index changed.
That is a part you have to add with the right path in it, almost the same as
the other selected indexes changes.

However instead of filling the rowfilter there you place the path to your
documentfolder.

I could not test that so I kept that open.

Cor
 
Sorry Cor,

I feel stupid now but im confused again:(

I guess I need to add something like:

Private Sub lstDocuments_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstDocuments.SelectedIndexChanged
If mlLoading = False ThenEnd If
End Sub

or am I totally not understanding this right?

Cheers and Many Thanks
MCN
 
Simon,

I thought this row than
Me.txtFileLocation.Text = Me.lstDocuments.SelectedValue.ToString

Cor
 
Hi Cor,

Thanks thats the one, just one thing tho, how do I get my textbox to be
Blank until I click on a document?

On the below, its displaying the last shown path of the last clicked on
document untill I click on the next docuemnt then it shows that so on and so
one, if ya get my meaning?

Cheers
MCN
 
Simon,

When you want you can set in every index change event
Me.txtFileLocation.text = ""

Cor
 
Back
Top