|
Hi dudes,
In VB6 we could add a child node to a treeview control by specifying a key for an existing node, then a relationship then the new node to be added to the tree. How can i do something like that in vb.net, given that from the add method of the .net treeview there isn't even one thats requiring the parent key and relationship?
Thanks spans in advance
|
|
|
|
|
dim tnode as new treenode("text") ' is the main node
treeview.nodes.add(tnode)
dim tsubnode as new treenode("text") ' is the subnode
tnode.nodes.add(tsubnode)
this should give you 1 main node with 1 subnode
hope this helps
|
|
|
|
|
Thanks TDDragon for your reply,
The thing is I do not know the depth of the tree before-hand and I am adding the child nodes recursively, its a something like an explorer program. So i would need to add whatever child node to any parent whose key i know
|
|
|
|
|
if you go tru it parent node by parent node you can do it like folowing:
dim tnode as treenode()
dim subnode as treenode()
if "check the node you need to add" = "parent node" then
tnode = new treenode("text")
treeview.nodes.add(tnode)
else
subnode = new treenode("text")
tnode.nodes.add(subnode)
end if
remember this will only work if you make you'r treeview parentnode by parentnode
if not (you need to add a node to parentnode1 while you already created parentnode3) then maybe this might be some help
'first create alle parent nodes and give the tag property a key value
'then iterate true you're parent nodes and where node.tag = key add a subnode
for each t as treenode in treeview.nodes
if t.tag = key then
dim subnode as new treenode("text")
t.nodes.add(subnode)
end if
loop
this way will take more time so if possible I would recomend the first way
hope this helps
|
|
|
|
|
Thanks man, used the 2nd one coz i ended up having to 'lazy-load' the tree. thanks spans
|
|
|
|
|
Dear All,
We are developing a financial application in Visual Basic 6.0 with SQL Server 2000 at the back end database and Crystal Reports as reporting tool,I am facing some problems with Visual Basic 6.0,my questions are as follows:
1) We are using MSHFlexGrid to display data , my question is that can we make the cells of MSHFlexGrid editable, I mean that user can enter or edit the data displayed in the datagrid,is this possible in Visual Basic 6.0,are there any controls for it and if this is not possible than how can we achieve this?
2) Can I insert controls in the datagrid(MSHFlexGrid), like if I want to display check boxes in the first of grid that when that when the user check the check box the entire row is selected,if it is not possible than how can we achieve this.
3) Is it possible to make the columns "Sortable", I mean if I click at the top of the column than the entire column is sorted, if this is not possible in Visual Basic 6.0 than how can we add this feature.
I would be waiting for your replies and suggestions so please reply as soon as possible.
Regards,
Taqi Raza.
|
|
|
|
|
hi,
1. yes, you can edit the data from your flex grid.
2. im not sure for flex grid but in MSHFlexGrid it is possible to put a check box in a row.
3. also im not sure in flex grid if it is possible but in MSHFlexGrid1 it is possible to do that.
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
Thanks, can you please tell how to achieve 1 and 2 and if possible than also please tell that how can we achieve number 3,1 and 2 are on our priority,which properties we can use???
|
|
|
|
|
Hi
I am trying to implement complex databinding concept to a datagrid some how managed to insert one table records in datagrid and struggling to bind other tables which been created in sql2005.
(using tableadapters,dataset)it will be greatly appreciated if you guys can share your knowledge and experiences.
many thanks
firasat
vb.net expertise
|
|
|
|
|
Here is the problem: I have to write vb application that will be used in local area network, so anyone who knows some kind of book or tutorial about programming vb application for network users
Thanks to anyone how will has time to answer me
Thanks again
|
|
|
|
|
You can just use network paths the same as any file paths. What are you hoping to achieve over your LAN ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
I stored in the database the link of an appropriate photo as a string
How i can pass this string to the pictureBox to display the photo
Thanks in advance
Assaf
|
|
|
|
|
Did you read MSDN ? Picturebox does not take a path, it takes an image. So, you need to create one, as in
picturebox.Image = new Image(path)
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
Thanks Christian i check the MSDN but i didn't find the one say it
instead i found a solution:
"Me.PictureBox1.Image = Image.FromFile(drt)
Where drt is the link from the database"
But can clarify your point.
Please
Thanks in advance
Assaf
|
|
|
|
|
If the "link" is a path in the local file system, you can put it in the ImageLocation property of the PictureBox .
If the "link" is an URL, you have to request the image from the server, load it into a Bitmap object and assign it to the Image property of the PictureBox .
---
single minded; short sighted; long gone;
|
|
|
|
|
How can i eject my CDROM ? (Using VB.NET)
|
|
|
|
|
i think this sample code can be useful :
<br />
<br />
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Int32) As Int32<br />
<br />
Private Sub Btb_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_open.Click<br />
Dim lRet As Int32<br />
Dim returnstring As String<br />
lRet = mciSendString("set CDAudio door open", returnstring, 127, 0)<br />
End Sub<br />
<br />
Private Sub Btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click<br />
Dim lRet As Long<br />
Dim returnstring As String<br />
lRet = mciSendString("set CDAudio door closed", returnstring, 127, 0)<br />
End Sub<br />
|
|
|
|
|
Hi,
I had checked this method before, but it opens just the first CD/DVD Drive.
I am interested to know if any code exists to open other drives too?!
(To do this, I used to send a click on Eject verb in drive's context menu! which is quite absurd! but life-saving)
|
|
|
|
|
Hi all,
i have been thinking on this problem for a while now - How do i process data from a serial device?
i have a serial connetion to a fire alarm system that sends ascii characters to the computer, i have esablished comms to the device, and have a method that is fired on every byte of data received.
Problem is the device sends the data in three byte wide blocks, so for example status,channel and then the checksum which is (status+channel). i have tried various method of circular buffers and pop-queues to try and process this but with no success!
for example the device would send ....14 then 1 then 15.
14 01 15 - this would represent fire on sensor 1
i am trying to write a method that every time a byte is received it stores it to a buffer and then processes it to try and put them in seperate variables.
example...
abnormality = buffer(x)
channel= buffer(x+1)
checksum = buffer(x+2)
Here is some rough example code but its not working correctly, does anyone have any ideas?
Thanks
<br />
<br />
Dim queue(6) As Integer<br />
Dim startPos As Integer = 2<br />
<br />
<br />
Private Sub ProcessData(ByVal data As Integer)<br />
Dim test As Boolean = False<br />
Dim checksum As Integer, channel As Integer, abnormality As Integer<br />
Dim alphaBuffer As Integer, betaBuffer As Integer, gammaBuffer As Integer<br />
Dim mytxt As String<br />
<br />
'step1 fill queue at index 2 - starting point<br />
<br />
queue(startPos + index) = data<br />
<br />
index = index + 1<br />
<br />
If index = 3 Then<br />
<br />
'step2 test bytes <br />
alphaBuffer = queue(2)<br />
betaBuffer = queue(3)<br />
gammaBuffer = queue(4)<br />
<br />
If gammaBuffer = CalculateChecksum(alphaBuffer + betaBuffer) Then<br />
<br />
abnormality = alphaBuffer<br />
channel = betaBuffer<br />
checksum = gammaBuffer<br />
<br />
<br />
Me.Label2.Text = abnormality & " " & channel & " " & checksum<br />
mytxt = Me.Label2.Text & " " & Me.ListBox1.Items.Count<br />
Me.ListBox1.Items.Add(mytxt)<br />
'LeftShift(queue)<br />
<br />
<br />
Else<br />
<br />
LeftShift(queue)<br />
startPos = 1<br />
<br />
End If<br />
<br />
<br />
End If<br />
<br />
If index = 4 Then<br />
<br />
'step2 test bytes <br />
alphaBuffer = queue(2)<br />
betaBuffer = queue(3)<br />
gammaBuffer = queue(4)<br />
<br />
If gammaBuffer = CalculateChecksum(alphaBuffer + betaBuffer) Then<br />
<br />
abnormality = alphaBuffer<br />
channel = betaBuffer<br />
checksum = gammaBuffer<br />
<br />
<br />
Me.Label2.Text = abnormality & " " & channel & " " & checksum<br />
mytxt = Me.Label2.Text & " " & Me.ListBox1.Items.Count<br />
Me.ListBox1.Items.Add(mytxt)<br />
'LeftShift(queue)<br />
<br />
<br />
Else<br />
<br />
LeftShift(queue)<br />
startPos = 0<br />
<br />
End If<br />
<br />
End If<br />
<br />
If index = 5 Then<br />
<br />
'step2 test bytes <br />
alphaBuffer = queue(2)<br />
betaBuffer = queue(3)<br />
gammaBuffer = queue(4)<br />
<br />
If gammaBuffer = CalculateChecksum(alphaBuffer + betaBuffer) Then<br />
<br />
abnormality = alphaBuffer<br />
channel = betaBuffer<br />
checksum = gammaBuffer<br />
<br />
Me.Label2.Text = abnormality & " " & channel & " " & checksum<br />
mytxt = Me.Label2.Text & " " & Me.ListBox1.Items.Count<br />
Me.ListBox1.Items.Add(mytxt)<br />
'LeftShift(queue)<br />
<br />
Else<br />
<br />
LeftShift(queue)<br />
startPos = 0<br />
index = index - 1<br />
<br />
End If<br />
<br />
<br />
End If<br />
<br />
<br />
If index = 6 Then<br />
<br />
'step2 test bytes <br />
alphaBuffer = queue(2)<br />
betaBuffer = queue(3)<br />
gammaBuffer = queue(4)<br />
<br />
If gammaBuffer = CalculateChecksum(alphaBuffer + betaBuffer) Then<br />
<br />
abnormality = alphaBuffer<br />
channel = betaBuffer<br />
checksum = gammaBuffer<br />
<br />
<br />
Me.Label2.Text = abnormality & " " & channel & " " & checksum<br />
mytxt = (Me.Label2.Text & " " & Me.ListBox1.Items.Count)<br />
Me.ListBox1.Items.Add(mytxt)<br />
LeftShift(queue)<br />
<br />
Else<br />
<br />
LeftShift(queue)<br />
startPos = 0<br />
index = index - 1<br />
<br />
End If<br />
<br />
<br />
End If<br />
<br />
<br />
<br />
If index = 7 Then<br />
<br />
index = 0<br />
<br />
End If<br />
<br />
<br />
<br />
<br />
End Sub
|
|
|
|
|
Hi,
I need some more info before I can propose an alternative approach. Hence:
1. Is there a minimal time gap between consecutive messages ?
2. How many bytes do you expect per second ?
3. What is the baud rate ?
4. "but its not working correctly" please explain ?
|
|
|
|
|
thanks for your reply
1. Is there a minimal time gap between consecutive messages ?
2. How many bytes do you expect per second ?
The device responds to ENQ (ascii char 5), when its first switched on it sends the same three bytes three times and then shutdown again or around 6 seconds if no ACK signal is sent, if the device is sent ACK (ascii char 6) then it starts to sent data.
so it sends status byte - send ACK back it then sends channel byte and so on.
3. What is the baud rate ? maximum 4800, 2 stop bits and odd parity
4. "but its not working correctly" please explain ? I meant my code, when i have received the data...status,channel,checksum - how do ensure the data is processed correctly in the correct order and not out of sync.
for example sometimes when comms is etablished, if the device is already sending data, the first character at this point may be the channel rather than the status the processing method has to weed this out and sync to the correct byte.
Thanks
|
|
|
|
|
Hi,
thanks for the info. This seems to be a very nice device, it allows for very safe
data transmission. These are my ideas now, they relate to the SerialPort class, not
to your current code; I prefer the synchronous read mode, that is: some thread
does all the communication, both sending and receiving, in lock step, there is no
need to have asynchronous reads since you can be in charge of everything.
SYNCHRONOUS COMM MODE
1. clear the serial input buffer (with DiscardInBuffer)
2. send command to start the communication
3. wait some time (say 1 sec)
4. read available bytes, no more than 9 are required; if they are not present, reject all
(there is a Read that fills a byte buffer, I'll call it b)
5. send command to stop the communication
DATA PROCESSING
1. check that 9 bytes obey xycabCABz pattern; i.e. make sure bytes 5to7 are same as 2to4;
if not reject everything
we will use xyc or yca or cab (normally x=a, y=b, z=c but we dont need that)
2. begin loop three times, with i=0/1/2
3. check b(i+2)=b(i)+b(i+1), if so goto step 6
4. next loop iteration (this means if for some reason a strange byte got in, ignore it)
5. we failed to find a valid checksum, reject everything
6. we got valid data in bytes i,i+1,i+2
IMPLEMENTATION IDEAS
I would have:
- a byte array b holding 9 bytes (it can be reused over and over)
- a method doing the comm part, i.e. filling b
- a method doing postprocessing, returning the index i of the first useful byte,
or -1 to indicate rejection
Hope I explained it well.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for your advice,
i will try and look into implementing your method.
thanks again
|
|
|
|
|
Hi! I need Help once Again.
I used this command to show the orders a particular customer made.
DataGridView1.Rows.Add(str0,str1, str2, str3, str4, str5)
Now, How can I send all the entry From DataGridView1 to a common DataBase where all the orders of all the customers are stored.
(Only differentiated by the Customer ID ,str0 = CustomerID)
(In the DataBase You can get orders made by a particular customer by the CustomerID)
So, can anyone tell me How to Send all the Orders made a Customer to the Common Database.(I heard about the Update method and all)
But any Help is Appreciated.
(as the orders are made it Will be shown in the DataGridView(only for the current customer))
-Thanx-
|
|
|
|
|
Hi Nanco,
From the way you describe the process, I understand that you have made a form with (probably) textboxes. The user enters order information into these boxes which you then gather into the DataGridView1. Assuming that this is correct, and that you are using vb.net (please say you are)...
The best way to proceed is to start using a DataAdapter and DataSet, linked to the database table that you want to store the orders in. Next you use this dataset as the datasource for the datagrid, and last but not least, you register the user input (textbox values) to the dataset and not to the datagrid. This way it is infinitely more easy to retrieve existing orders (DataAdapter.Fill(DataSet) ), and more importantly, the datagridview can be used to allow the user to add and/or edit his order (DataAdapter.Update(DataSet) ) The DataAdapter will take care of retrieving and saving data to and from the database.
Hope this helps you on your way,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|