|
Hi,
1. Why the cross-post? You expect better answers from VB.NET programmers?
2. nice picture, now I (think I) know what it is you want.
3. you know you can turn a Form into a regular Control, so you can add it to another
Form? All it takes is setting TopLevel false. Maybe that solves all your requirements?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
1. i never posted on any other forum than the vb one. i just thought i'd make a dedicated topic for this concept as the other one was for painting stuff.
2. thankyou.
3. yes ironic i was actually contemplating this move as i got your email. about to give that a go. But still, i don't know if it will help, maybe it will. we'll see
|
|
|
|
|
The ANZAC wrote: i never posted on any other forum than the vb one
Sorry I got confused then, thought I had just seen this elsewhere, I guessed on the C# forum.
yes ironic i was actually contemplating this move as i got your email. about to give that a go. But still, i don't know if it will help, maybe it will. we'll see
AFAIK it is intended for such use, but again I never did it: when Controls don't do what
I want, I usually tackle the problem with fewer of them (the "lightweight" approach),
avoiding the fight, rather than more of them and/or UserControls.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
i need help writing a block of code that can scan the entire networked pcs ip and put the result into a listbox.As i not sure of even where to start i don't even know how to write it.Will be adding a polling function to it
|
|
|
|
|
Have you started on the project?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Here I am in a situation where three events should occur one after another provided that the
preceding event occured successfully.
For eg. When i click a button, the first event prints the first report and when the first
printing succeds ,it should print the second report.But sometimes, the first report printing
cannot be done because some printing error may occur.In that case,the program should stop there.
How can it be done?? I need a general idea only.
Could you guys help me out??
X
|
|
|
|
|
|
Another one of those cross posters.
"The early bird may get the worm, but the second mouse gets the cheese" - anonymous, found in Uncle John's Bathroom Reader
|
|
|
|
|
Doesn't sound like your talking about events. you only have 1 event. the click event. inside that event you need to call 3 functions. each function should be a boolean so that you know whether or not to continue.
Sub Button_click(sender as object, e as system.eventargs) handler button.click
If bPrintFirstReport Then
If bPrintSecondReport Then
If bPrintThirdReport Then
'
else
'report error
End If
Else
'report error
End If
Else
'report error
End If
end sub
|
|
|
|
|
VB6 Property set with two parameters won't port to VB.Net
I'm trying to port a VB6 class called VBXML to VB.Net in such a way to also minimise changes to client code using the class.
In VB6 the class has a property called FieldValue that is defined with 2 parameters:
Public Property Get FieldValue(strXPath As String) As Variant<br />
<br />
CurrentField = strXPath<br />
FieldValue = CurrentFieldValue<br />
<br />
End Property<br />
<br />
Public Property Let FieldValue(strXPath As String, pvarNewValue As Variant)<br />
<br />
CurrentField = strXPath<br />
CurrentFieldValue = pvarNewValue<br />
<br />
End Property
Now without going into the innards this Property Let allows client code to be written like this:
Dim obj As VBXML<br />
<br />
Set obj = New VBXML<br />
obj.FieldValue("ID") = 10<br />
obj.FieldValue("Name") = "Gordon Brown"<br />
obj.FieldValue("Address") = "10 Downing Street"
This client code in VB6 generates a call to the property let with the string argument strXPath being passed as "ID" or "Name" or "Address" in the 3 examples above and with the variant pvarNewValue being passed as 10 or "Gordon Brown" or "10 Downing Street".
This is very convenient and intuitive syntax a bit like we used record sets:
rs.Fields("ID") = 10<br />
rs.Fields("Name") = "Gordon Brown"<br />
rs.Fields("Address") = "10 Downing Street"
It seams that equivalent VB.Net Property Let declarations are only ever allowed to have 1 parameter otherwise you receive an error: 'Set' method cannot have more than one parameter
So the question is how do I rewrite the class property so that client code will be able to be of this form and with minimal changes? The client code is also being ported to VB.Net by the way.
|
|
|
|
|
Ex:
Test("bbbb") = "hello"
Public WriteOnly Property Test(ByVal o As Object) As String
Set(ByVal value As String)
MsgBox(o)
Msgbox(value)
End Set
End Property
|
|
|
|
|
I did wonder what the relationship was between the argument in the declaration of the property itself and the argument in the declaration of the Set of the property in VB.Net. Now I know! Thanks for the very quick answer.
|
|
|
|
|
A list of numbers is input in a list box, say (4.8,6.9,8.0,3.2). The sum of these numbers are displayed in a textbox using:
For Index As Integer = 0 To lstbox1.Items.Count - 1
Total += CDbl(lstbox1.Items(Index))
Next Index
When one of those numbers are removed from the listbox, the total is accumulated , that is the new total is added to the old one. How can I correct this so that the total given is always, the total of the numbers in the listbox.
|
|
|
|
|
try an occasional Total=0
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I need help with updating an access database table(access database is included in my project). my data comes from an xml that will periodically be updated and displayed on a DataGrid field. I manage to display the data onto datagrid and now I want to copy the displayed data into an access database table. Does anyone knows how to do that?
Thanks for your help
Maria
|
|
|
|
|
1. Iterate through the rows in your DataGrid control.
2. For each row, execute an INSERT INTO...VALUES DML query that inserts a row of data into a table in your Access database. This query could be constructed dynamically as a string or it could be a parametetized query stored in the Access database.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks Paul,
This is what I have done so far but it doesnt work:
##################################################################
Dim newRows as DataRow = DatabaseDataSet.Tables("Table1").NewRow()
Dim dr As DataRow
For Each dr In Me.DataGrid1.Rows
newRows = dr
DatabaseDataSet.Tables("Table1").Rows.Add(newRows)
Next
##################################################################
Please help!
Maria
|
|
|
|
|
What do you mean 'it doesn't work'? What do you expect it to do? Do you get an error? You need to be more specific.
All your code appears to do is add rows to a Table in a DataSet. Where is your code to connect and add the data to your Access database? I suggested a way of doing this in my previous post.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Have a look at this article[^]. It explains how to use data adapter and command builder classes to update an underlying data source when data in a datatable is modified. The code in the article is written for use with SQL Server, but if you change the System.Data.SqlClient classes used to their equivalents in the System.Data.OleDb namespace then you can achieve the same result with an MS Access database.
Any more questions, just ask.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
mparlitu wrote: Dim row As DataRow
This declaration is incorrect. row should be defined as a type of DataGridViewRow .
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Paul,
I have changed the type to DataGridViewRow and now I get the error saying:
Error 1 Class 'System.Windows.Forms.DataGridViewRow' cannot be indexed because it has no default property.
####################################
For Each row In DataGridView1.Rows
dt.Rows.Add(row)
row("Label") = DataGridView1.Columns("Label")
row("Data") = DataGridView1.Columns("Value")
Next
####################################
If I take out this two lines...
row("Label") = DataGridView1.Columns(0)
row("Data") = DataGridView1.Columns(1)
... I get the database updated with: DataGridViewRow { Index=1 } up to DataGridViewRow { Index=31 } one for each record found in DataGrid; on the first column of the table.
Do I need to index each cell in DataGrid?
Thank you,
Maria
|
|
|
|
|
You should really read the documentation[^] before posting questions like this. The error message explains what the problem is and consulting the documentation would have made it clear what you needed to change.
The DataGridViewRow class doesn't have a default property. To get/set the value of a particular cell in a row, you need to reference its Cells collection. Something like this:
row.Cells("Label").Value = DataGridView1.Columns("Label")
Hope this helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks Paul,
It is working now!!! I have all my data from DataGrid moved to Access.
Thanks again, I really appreciate your help!
x x x
Maria
|
|
|
|
|
Great! Happy to help
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I have a custom control and am painting a custom border, how do i paint this outside of the bounds of the control from within the control itself. It's just a custom panel so its a straight rectangle.
|
|
|
|