Jump to content
Xtreme .Net Talk

Shaddow

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by Shaddow

  1. Here's the deal: I have an xml configuration file that I want to use to hold various values. ie: basic configuration, recent files etc. I put all code for this into a class called CONFIGXML.vb I want to just call a function with a integer parameter that will either fill a menu item on form one if a 1, or fill a configuration form if a 2. how do I get independent control over both forms from this class?
  2. XML File Processing Question... For Each Node In XmlDocument.Item("configuration").Item("appSettings") If Node.Name.ToString = "add" Then MsgBox(Node.Attributes.GetNamedItem("key").Value.ToString) End If Next Node the file. <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="inputGoogleKey.Text" value="" /> <add key="cbxBroadband.Checked" value="False" /> <add key="cbxTopMost.Checked" value="False" /> <add key="txtRecentFile0.Text" value="" /> <add key="txtRecentFile1.Text" value="" /> <add key="txtRecentFile2.Text" value="" /> <add key="txtRecentFile3.Text" value="" /> </appSettings> </configuration> What happens is that the messagebox seems to repeat the file multiple times. finally the messagebox get's weird and then it'll finally close. any ideas? my brain is feeling foggy....
  3. here is the deal. I have an xml file that I want to read. my load function works perfectly... it takes a string filename from the loaddialogbox. this is then sent and included in the recent files menu. when selected I get the filename back that I wanted, the file opens but somereason fails to load. any suggestions? here is the code. ----- -- this one works.... Private Sub MenuItemLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemLoad.Click ' Declare a FileInfo object for the config file. Dim strTemp As String OpenFileDialog1.Filter = "Xml files (*.XML)|*.XML" OpenFileDialog1.ShowDialog() Dim XmlDocument As System.Xml.XmlTextReader Dim q As Integer q = 0 'MsgBox() If OpenFileDialog1.FileName <> "" Then ListView1.Clear() SetColumnNames() ListView1.View = View.Details Me.Refresh() Try XmlDocument = New System.Xml.XmlTextReader(OpenFileDialog1.FileName.ToString) Catch MsgBox("Error Opening File") Exit Sub End Try Try Dim l As ListViewItem Dim x As Integer x = 0 Do While (XmlDocument.Read()) If XmlDocument.Name.ToString = "Link" Then Dim linkinfo(2) As String Dim elementholder As String elementholder = XmlDocument.ReadElementString() linkinfo = elementholder.Split(",") l = New ListViewItem(linkinfo(0)) l.Font = New Font("Courier new", 10, FontStyle.Underline) l.ForeColor = Color.MediumBlue l.UseItemStyleForSubItems = False l.SubItems.Add(linkinfo(1)) l.SubItems.Add(linkinfo(2)) ListView1.Items.Add(l) Me.Refresh() End If Loop Catch ex As Exception 'MsgBox(ex) MsgBox("error in loading file") Exit Try Finally XmlDocument.Close() End Try Me.Refresh() End If End Sub --- This one fails. Dim XmlDocument As System.Xml.XmlTextReader ListView1.Clear() SetColumnNames() ListView1.View = View.Details Me.Refresh() 'MsgBox(CType(sender, MenuItem).Text.ToString) 'Exit Sub Dim myFile As String myFile = CType(sender, MenuItem).Text.ToString MsgBox("MyFILE: " & myFile) Dim mystring As String If Len(myFile) > 0 Then Try mystring = CType(sender, MenuItem).Index.ToString XmlDocument = New System.Xml.XmlTextReader(mystring) Catch MsgBox("Error Opening File") Exit Sub End Try Dim l As ListViewItem Dim x As Integer x = 0 Try Do While (XmlDocument.Read()) 'MsgBox(XmlDocument.Name.ToString) If XmlDocument.Name.ToString = "Link" Then Dim linkinfo(2) As String Dim elementholder As String elementholder = XmlDocument.ReadElementString() linkinfo = elementholder.Split(",") l = New ListViewItem(linkinfo(0)) l.Font = New Font("Courier new", 10, FontStyle.Underline) l.ForeColor = Color.MediumBlue l.UseItemStyleForSubItems = False l.SubItems.Add(linkinfo(1)) l.SubItems.Add(linkinfo(2)) ListView1.Items.Add(l) Me.Refresh() End If Loop Catch ex As Exception -- exception always is right here.... MsgBox("EXCEPTION READING FILE VALUE: " & XmlDocument.Name.ToString) MsgBox("File Opened, error in load") Exit Try Finally XmlDocument.Close() End Try Me.Refresh() 'MsgBox("Under Construction") End If End Sub anyway. I'm confused as why if the file is there and it opens, (it's there, and in correct format). but fails on the read....
  4. This seems to work. (I'm sure it wouldn't if the data processed wasn't integer(but still numeric).) however inelegant. I'll probably play with this a bit more to cover some more cases and a definite default to string if everything else doesn't work... Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _ Implements IComparer.Compare Dim lv1, lv2 As ListViewItem lv1 = DirectCast(x, ListViewItem) lv2 = DirectCast(y, ListViewItem) Dim holder1, holder2, comptype As String holder1 = lv1.SubItems(col).Text holder2 = lv2.SubItems(col).Text If IsNumeric(holder1) And IsNumeric(holder2) Then comptype = "int" Else comptype = "str" End If If comptype = "str" Then 'Do string compare Return [string].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text) End If If comptype = "int" Then 'Do integer compare If Integer.Parse(lv1.SubItems(col).Text) > Integer.Parse(lv2.SubItems(col).Text) Then Return -1 If Integer.Parse(lv1.SubItems(col).Text) < Integer.Parse(lv2.SubItems(col).Text) Then Return 1 Return 0 End If ' End If End Function
  5. this last part doesn't work. I believe it is because objects are passed not either integers or strings. i tried the code but It never executes. I think that its rather close to what I'll end up using. once I can do a quick determination on if the column is numeric or character based.
  6. works fantastic. however (isn't there always a however?) this would invalidate any sorting by any other column that might actually be textual. Is there some way to overload the compare function?
  7. Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _ Implements IComparer.Compare Return [string].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text) End Function This is in the class. and what actually compares the two.
  8. I have my listview implimented, working. colored to my hearts content.... working on sorting and have implimented a class called ListViewItemComparer. (as seen in MSDN, here and other places). the sorting works..... kind of.. it sorts based on the input being a string. I however want it to sort based on it being an integer. (ie. the following sort issue happens: 1, 2, 3, 4, 5, 6, 21, 33 results in: 1, 2, 21, 3, 33, 4, 5, 6 I am thinking that a solution falls into 1 or both of 2 categories. 1. possibly rewriting the ListviewItemComparer. and maybe funkifying some functions that will allow an 'extra' parameter to allow some specific casting or 2. I should beat my head against the table and then try someone 'elses' simpler solution.... anyone ? Thanks
  9. ok. HOW? I will have to do such in the near future. I liked the lvi.UseItemStyleForSubItems = False worked great. but how do I get to the individual subcells. lvi.font etc worked for the item but lvi.subitems..... doesn't allow the font change the same way (or at least I seem to be missing it.
  10. I want to be able to color the first column like a hyperlink and leave the rest of them alone. I can acheive the coloring of the full deal by: .Font = New Font("Courier new", 10, FontStyle.Underline) .ForeColor = Color.MediumBlue on a ListView Item. But I only want the one column changed.... any suggestions? R
  11. Found my Answer. duh.... ListView1.View = View.Details This seems to be what causes it to show itself.....
  12. I've created a list view. I can add something into it. the problem is that I can't seem to get the columns to show up in the form. I can msgbox them out and show that they exist, but no view on the listview control. any suggestions?
  13. the form is the primary start object. and is already instantiated. something like this. the form opens and on a button of the form I have a button. it calls a function from the added module (which then takes control and goes from there. What I want is a way, once in that added module to access form functions, methods and properties. all I get available is a small list that starts with something like form1.ActiveForm.something etc. there are no references to any functions even though I made them public. or am I just missing something....
  14. I'm missing something between the jump from an earlier version of VB. I use to be able to do something like this: (say I have 2 modules and 1 form, form1, and main as modules and form1 as a form. something like this use to work. (inside the main module) Form1.(whatever sub or funciton is) in the new VS in the VB.net stuff I'm not able to do this. I get something like . (inside main module) Form1.(small list with like ActiveForm) but none of my public functions from form1(the module) I think this is a brain cramp that I'm missing something very obvious. Thanks.:mad: :mad:
×
×
  • Create New...