|
Hey,
I populate my tree using a recursive function to load hte xml file, and can add nodes to the tree which update the xml file using MSXML. Can i use MSXML to update the data between tags in the XML file:
<category>
<name>Data To be Updated</name>
</category>
(the tree node names) based on the selected tree node being renamed using the AfterLabelEdit command?
Thanks for the help
Chris
|
|
|
|
|
Well, since the TreeView control doesn't support Data Binding, you'll either have to add that support by creating a custom TreeView control or use a similar procedure to write the data back out that you used to get it into the TreeView.
You'll have to do some extra research on these methods to see what's going to work the best for your situation and requirements.
You might want to take a look at Extending the TreeView Control[^] on MSDN for a how-to on adding Data Binding.
When you rename a node in the Tree, the TreeView will fire a couple of events. You use the source data to find the appropriate node in the DataSet and update the data in the DataSet. Now, when your done, the DataSet object can write the resulting XML file back out for you. You won't have to iterate through the nodes and write eash one out by hand. That's why I highly suggest you use a DataSet object for your Tree data source.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your input, appreciate it.
I have managed to load the xml file in to a dataset before, but was unable to make the treeview use this dataset.
I will read that article and let you know how i get on.
Thanks again
Chris
|
|
|
|
|
Hey Dave,
I have written a function that can update the xml file using a DataSet.
My problem is I call this function in the AfterLabelEdit method and it runs.
But it updates the old name with the old name! as i cannot catch the new name that is typed in to the selected treenode until the AfterLabelEdit method as finished.
Do you have any suggestions of how to get the newly type name so when enter is pressed and the AfterLabelEdit method is run the new name can be used to update the old one using the update dataset function.
Thanks you for your help
Chris
|
|
|
|
|
What's the code in the event handler? Are you using the .Text property of the e.Node object that's passed to the handler? You will get the Node that was edited in the e.Node object AND you will get the new label text in the e.Label object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey,
Cheers again for the help, i have used a timer and made the AfterSelectEvent fire that. But will be changing my treenode to use a real dir structure soon, so i will keep that in mind thankyou.
Another question is that i am now using DSOFile to load MS Office file properties in to the form when the file node of my tree is double clicked.
This works and loads the file properties in to the form first time the node is double clicked, but if you try to go back to that file an error occurs saying that it cannot load the file properties because the file is open.
Is there anyway to close the file as soon as the properties have been retrieved?
Thank you for all your help
Chris
|
|
|
|
|
You can force the release of the underlying COM object by using Marshal.ReleaseComObject() on the instance of the DSO object you created. Try this:
Imports System.Runtime.Interop
.
.
.
' I'm assuming you're using the PropertyReadClass...
Dim dso As New DSOleFile.PropertyReaderClass
'
' Do whatever you need to with the object here...
'
' Now, release the unmanaged object and it's underlying resources.
Marshal.ReleaseComObject(dso)
' Drop our managed reference to the object.
dso = Nothing
.
.
.
And let the garbage collector do the rest...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey,
Thanks for the reply. I have tried using the Marshal.ReleaseComObject but it does not seem to close the file, giving the error 'The file is open and cannot be read'. I have used hte import of InteropServices too.
my code is:
<br />
'DSO Properties<br />
Dim oDsoPropReader As DSOleFile.PropertyReader = New DSOleFile.PropertyReaderClass<br />
Dim oDsoFileProp As DSOleFile.DocumentProperties<br />
<br />
oDsoFileProp = oDsoPropReader.GetDocumentProperties(strFullPath) '<-- This line causes the error<br />
<br />
tbAuthor.Text = oDsoFileProp.Author<br />
tbFormat.Text = oDsoFileProp.AppName<br />
lblDateCreated.Text = oDsoFileProp.DateCreated<br />
lblDateModfied.Text = oDsoFileProp.DateLastSaved<br />
<br />
Marshal.ReleaseComObject(oDsoPropReader)<br />
<br />
oDsoFileProp = Nothing<br />
oDsoPropReader = Nothing<br />
Is my code wrong?, this help is really appreciated.
Chris
|
|
|
|
|
I have solved hte problem i also released the DocumentProperties as well as the reader, thanks for all your help Dave.
Chris
|
|
|
|
|
http://www.thecodeproject.com/vb/net/classinspector.asp[^]
This is a great little tool that can make implementing a snap.
There is a minor bug in the program that truncates some properties.
For instance, the Textbox property _PasswordChar has a default of Chr(0) which is a 'null.' The problem is that the textbox sees a null as an EOF and truncates the string. A simple solution is to remove the null char. To do this, change the line in showEnum and showControlProps from currentText = sb.ToString to read currentText = sb.ToString.Replace(Chr(0), "")
|
|
|
|
|
could anyone tell me why i've got this error message and how i can solve it?
thanks
Server Error in '/Log_In' Application.
--------------------------------------------------------------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 53: Loop
Line 54:
Line 55: DdlNoperiod.Items.AddRange(New Object() {"10", "11", "12", "13"})
Line 56:
Line 57: 'Put user code to initialize the page here
Source File: C:\Inetpub\wwwroot\Log_In\calendar.aspx.vb Line: 55
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
Log_In.calendar.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Log_In\calendar.aspx.vb:55
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
|
|
|
|
|
DdlNoperiod.Items.AddRange(New Object() {"10", "11", "12", "13"})
I think DdlNoperiod is DropDownList. You can add only ListItem() to the DropDownList using AddRange method.
Do like this.
DdlNoperiod.Items.AddRange(New Object() {new ListItem("10"), new ListItem("11"), new ListItem("12"), new ListItem("13") })
|
|
|
|
|
unfortunately, it doesn't work by that way.
|
|
|
|
|
I have a function that I need to convert from C# to VB.
C#
public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream)
{
int b1;
System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
while((b1=theStream.ReadByte())!=-1)
{
tempStream.WriteByte(((byte)b1));
}
return tempStream.ToArray();
}
My VB So far...
Public Function ConvertStreamToByteBuffer(ByVal theStream As System.IO.Stream) As Byte()
Dim b1 As Integer
Dim tempStream As New System.IO.MemoryStream
While ((b1 = theStream.ReadByte()) <> -1)
tempStream.WriteByte(((byte)b1))
End While
Return tempStream.ToArray()
End Function
i keep getting an error of: 'Byte' is a type, and so is not a valid expression. referring to the code in the while statement.
Please can someone help me to convert the function
Thank You
|
|
|
|
|
You have only one error in the line tempStream.WriteByte(((byte)b1)) . The VB equivelent of (byte)b1 is CType(b1, Byte) .
The full VB code should be
Public Function ConvertStreamToByteBuffer(ByVal theStream As System.IO.Stream) As Byte()
Dim b1 As Integer
Dim tempStream As New System.IO.MemoryStream
While Not ((b1 = theStream.ReadByte) = -1)
tempStream.WriteByte(CType(b1, Byte))
End While
Return tempStream.ToArray
End Function
|
|
|
|
|
here is a pretty cool site that converts vb to c# and vica versa - its not perfect it sure beats typing everything out -
http://www.developerfusion.com/utilities/convertvbtocsharp.aspx
|
|
|
|
|
Personaly I use SharpDevelop[^] which has a built in C# to VB.Net and VB.Net to c# converter. I use it a lot as I write in VB.Net as work and C# at home. It is quicker to convert whole classes than to rewrite from scratch, even though the conversion is only 99% perfect.
|
|
|
|
|
Note that this function is not very efficient. Why is b1 an integer to begin with? And as for reading a single byte at a time...
my blog
|
|
|
|
|
Hi, I want to display the data from Ms access database (ex: Northwind.mdb) to a DataGrid control in VB.Net by using the code only. I don't want to bind the datagrid to any data control. Is it possible to do that? If it is possible can any one give me some sample code to work with it? Now I learn how to bind the data grid with Data Adapter configuration wizard, but i think it is not flexible like the code.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
This should get you on the right track. Personally I like using the wizards but I use my own commands with the adapters and datasets that the wizard creates. This code works but don't like how it displays data in the datagrid. Maybe you can work it out. Enjoy
Dim oCmd As New OleDb.OleDbCommand()
Dim oDA As New OleDb.OleDbDataAdapter(oCmd)
Dim oDS As New DataSet()
Dim strCommand As String
Dim oConn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Northwind.mdb;Mode=ReadWrite; Persist Security Info=False")
strCommand = "SELECT * FROM <table name>"
Try
oConn.Open()
With oCmd
.CommandType = CommandType.Text
.Connection = oConn
.CommandText = strCommand
End With
Catch ex As Exception
MessageBox.Show("Failed to connect to data source")
Finally
oConn.Close()
End Try
oDS.Clear()
oDA.Fill(oDS)
DataGrid1.DataSource = oDS Let me know if you can't get this to work. Remember to use your own connection path and in the command string use the table name you are selecting from.
|
|
|
|
|
Dear Britnt7, Thank you very much for your sample code. Now it is working and I will learn to customize it as much as I can. But I have one more question. I put your give that give to me on the form load, and the data fill in the datagrid as I want but the grid is not display until I click on the plug sign (+) then it display the data as I want. Do you know how to ignore this plus sign? I mean when the form load with your code I can see the data display directly in the datagrid without click the plus sign to see the data in the grid. Thank you very much for your help!!!
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Dear Britnt7, I have one more question. In VB6 when I transfer the data from database to list view control, I have an opportunity to give the name of the column header to a difference name from the field of the table in database but I can use do while ... loop to put the data one by one in the list view. But the datagrid in VB.net seem that have no opportunity to code to change the name of the column, is it true? The reason is the database that I design is written in my own language. The field of the table written in English while the record is written in my own language. So when I display on the grid it display in english only so the column header could read in english but the record could not read. But when I change the font to my language the record could read (know the meaning) but the column header could not read. Any possible solution?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi..
Can anybosy telll me a gud site or a tutorial to know about web class libraries.I have a couple of pages that are common to quite a number of applications.
So would like to add them into a library storing at one places and calling them from various applications.Is it possible??
Thanks in anticipation
g
|
|
|
|
|
Hello,I have the following project and I have tried and tried but can't seem to get it. Can anyone help?
I have to write a program to campare the secant method with newton's method for finding the roots of each function:
x^3 - 3x + 1 with starting point Xo=2
x^3 - 2 sin x with starting point Xo=.5
The instructions also state to use the X1 value from Newton's method as the second starting point for the secant method and to print out each iteration for both methods. I appreciate any help.
|
|
|
|
|
L_JIMENEZ wrote:
I have tried and tried
What have you tried ? Where are you having trouble ?
L_JIMENEZ wrote:
I appreciate any help.
Sure, but no-one is going to do your homework for you. If you can post what you've got, and where you're stuck, we're all glad to help out.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|