|
hi, thanks for your answer.
the parameters i got from one of our engineers so i think they are ok.
the encoding setting i also became from him, but i`ll try it without the encoding tomorrow.
i first wanted to try the programm tonight at home but unfortunately i forgot that my notebook has no serial port is there any way to simulate a serial port?
thanks michael
|
|
|
|
|
belowzero wrote: the parameters i got from one of our engineers so i think they are ok.
The first rule of troubleshooting: There is no "thinking" allowed. You either know it or you don't. You either know you've tested and verified it, or you need to test and verify it.
belowzero wrote: is there any way to simulate a serial port?
Uh, without on ACTUAL serial port, how are you going to connect the RFID reader?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
at work i have a serial port only @home i don`t have one.
|
|
|
|
|
i found the problem. the timeout of the card reader was set to 40ms. i don`t know why, but the communication between my .net program, the serial port and the card reader needed a higher timeout.
|
|
|
|
|
Hi, I'm writing an application and I'm attempting to create a TableLayoutPanel and add/remove columns dynamically. However, I can't locate the method/ability to do so.
Is it possible to add columns to a TableLayoutPanel dynamically? If so, could you provide a small snippet?
Thanks!
|
|
|
|
|
Yeah, all you need to do is change the ColumnCount and RowCount properties. Also, check the documentation on the GrowStyle property to control automatic row or column add/delete. Once that's set, you'll have to create new ColumnStyles and/or RowStyles to define the column/row layouts and add them to the ColumnStyles and RowStyles collections.
TLP1.ColumnCount = 1
TLP1.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 100.0))
TLP1.RowCount = 2
TLP1.RowStyles.Add(New RowStyle(SizeType.Percent, 15.0))
TLP1.RowStyles.Add(New RowStyle(SizeType.Percent, 85.0))
When that's done, you can add controls to the new rows and columns with the TLP's Controls collection. You need to specify which column and row the control is going to end up in (0 based!) So, in the above example, the first (and only) column is 0, and the rows are 0 and 1.
TLP1.Controls.Add(TextBox1, 0, 0)
TLP1.Controls.Add(TextBox2, 0, 1)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you so much! That worked like a charm!
|
|
|
|
|
I have a few questions about the .NET Delegate. It seems like the delegate is consumed to change a value on the delegate's source form. My problem is, is that I need to change about 50 values (set them to blank). This (setting up a delegate) doesn't seem like the way to go about consuming an event that just merely changes textboxes to be blank. I don't need to return any value from form 1, but just fire the event.
Christian Graus: i've seen you reply to a few people's questions with the simple line 'use a delegate' or something to that effect. Just wondering what your take is on this situation.
Nathan Lindley
.NET Aficionado
-- modified at 11:16 Wednesday 4th October, 2006
|
|
|
|
|
OK. What are you trying to do with this?
Are you just trying to clear a form from a seperate class?? If so, then it's bad practice to do it from your class. If your class knew anything about the form it's trying to modify, it would then be permanently tied to that form and not be able to be reused somewhere else.
What you should be doing is sending back data to the form that it knows should signal that some processing is done. This signal can then be used as a trigger so the form clears its own textbox's. This is either done with a return value from your class' method, or from an event or callback delegate that your form subscribes to.
With this model, your class can be reused with any UI, be it a Compact Framework app, ASP.NET app, Web Service, ...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the response Dave
Dave Kreskowiak wrote: an event or callback delegate that your form subscribes to
I've been trying to work with the delegate again all morning, and i'm just missing the connection (in my brain) somewhere. Heres what I have...
Form1(Modify2.vb)
Create the delegate:
Public Delegate Sub ClearDel(ByVal clear As Boolean)
Create the event:
Private evtClear As ClearDel
Public Sub Register(ByVal objClear As ClearDel)
'raise event here?
End Sub
Public Sub fireClear()
'clearing code
End Sub
Form2(frmPayableInfo)
Private WithEvents mobjModify2 As Modify2
In the sub where I process, at the end i have this:
mobjModify2 = New Modify2
mobjModify2.Register(New Modify2.ClearDel(AddressOf eventClear)
and then i have the sub:
Public Sub eventClear(ByVal clear As Boolean)
clear = True
End Sub
So now the question is, how do I hook up the fireClear() event on Form1(modify2.vb) with the delegate. And where would I set the condition for the delegate to fire? Thanks again for the response.
Nathan Lindley
.NET Aficionado
|
|
|
|
|
Wow! You've got everything backwards and in the wrong classes.
First of all, get off the delegate kick and start explaining what you're trying to do. Since you're using two forms, the circumstances have now changed.
Does Form1 show Form2 as a dialog and wait for the user to close Form2? If so, then all you have to do in Form2 is expose the data as a few properties and resume execution from after the ShowDialog call:
' In Form1
Dim myForm2 As New Form2()
' ShowDialog is a blocking call, so nothing after it will execute
' until the dialog is dismissed by the user.
If myForm2.ShowDialog() = DialogResult.OK Then
' Get the data off of Form2 and do something it...
Dim x As Integer = myForm2.someProperty
' Clear the textbox controls...
ClearMyControls()
End If
' When using ShowDialog(), you MUST call Dispose on the object
' when you're done with it!
myForm2.Dispose()
Now, if you're running both forms simultaneously, you can expose some events in Form2 that Form1 can subscribe to:
' In Form2
Public Event SomethingHappened(ByVal someValue As Integer)
Public Sub SomeMethod()
' Do something then raise an event to say it was done.
RaiseEvent SomethingHappened(data)
End Sub
' In Form1
Dim myForm2 As New Form2()
AddHandler myForm2.SomethingHappened, AddressOf MyHandler
.
.
' Must match the signature of the SomethingHappened event!
Private Sub MyHandler(ByVal value As Integer)
' We were told something happened. Clear our controls!
ClearMyControls()
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the response Dave K
Like I said I am brand new to the whole delegate concept so I have no idea how they work. First let me just explain my situation. I have a form that displays a datagrid with customer info. when you double click the start of the row, it opens up a form (form2) that has a bunch of information based on the record that was clicked. When I submit this information (form2) I need to clear the datagrid (on form1) so that the user has to look up the ID of the person they updated (i probably should just reset the find, but thats another issue i can handle when i get this cross form communicating going), so there isn't old data. Okay. Now in your example:
Dave Kreskowiak wrote: ' In Form2
Public Event SomethingHappened(ByVal someValue As Integer)
Public Sub SomeMethod()
' Do something then raise an event to say it was done.
RaiseEvent SomethingHappened(data)
End Sub
What significance does the Integer in the argument have?
Nathan Lindley
|
|
|
|
|
nlindley7 wrote: What significance does the Integer in the argument have?
Nothing. It's just an example of how to pass data in an event.
If what you're doing in your datagrid is editing the details of that record and sending them back to the database, then you would probably show this detail form with ShowDialog(). After that statement returns (the user has finsihed editing this record and it was written back to the database), you can execute the code to refresh your datagrid's datasource.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey Dave TA ,
The datagrid displays a list of claims for each client. When an individual claim is clicked, a new form pops up that displays the details of that particular claim. When you edit/submit the details of this form (form 2), the values are submittied to a claimsDetails table. One of the details you can edit, happens to be the primary key of the claims/claimDetails tables. So the form submits data to the database that the datagrid reads from; hence needing to refresh that table. So I would assume the second example you showed is the one to follow?
Nathan Lindley
|
|
|
|
|
Actually, the best example to follow in this case would be the first one. After the details are edited in the second form, the original form has to refresh its dataset so it can display the new data. The second form doesn't need to stay up if it's not editing anything.
What I meant by "running two forms simulataneously" is that the user can switch back and forth between the forms at any time, or they are modeless. A modal form is a dialog box. You can't continue with the rest of the application unless that dialog box is dismissed (OK or Cancel).
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How to make a WebBrowser go through a proxy server?
I think you can do it by changing the proxy-settings in Internet Explorer, but can you do it without doing that?
Greetings - mik
|
|
|
|
|
No, the WebBrowser class will only use the proxy settings setup in Internet Explorer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Okay - how to set the proxy-settings in Internet Explorer then
And is it possible to use another control (like a downloaded) almost like WebBrowser with the ability of using proxy?
Thanks
|
|
|
|
|
I don't know of any 3rd party controls for this.
The WebProxy class in the .NET Framework 2.0 will NOT modify the system proxy settings. It will return a COPY of them though, which you can then modify for use in your own app. Don't get any cute ideas. The WebProxy class does NOT work with the WebBrowser class. It will only work with classes that are derived from the WebRequestclass, like HttpRequest.
You can either modify Internet Explorers proxy settings through the WinHttp API function WinHttpSetDefaultProxyConfiguration[^]. I do NOT recommend doing this, since it changes the proxy settings system wide!! ANY browser window that is open will have these new settings applied to it!!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have a couple of data tables that need to be integral to my project. While creating the project I read and write them from SQL databases. I'm worried that when I deploy the project the tables will be potentially unavailable to the user. Is there a preferred way to make the tables an integral part of the project itself? All editing of the tables is done through the project.
tias
|
|
|
|
|
If you're reading/writing this data to SQL Server, you could ship SQL Express with your app and keep the data in that. You wouldn't have to change very much code to keep it working. You're only other option is to save the data in local files, probably XML files or an Access database. But this option would require rewriting more of your code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave.
XML seems like a good option for me, but I cannot find information on how to bind an XML file to a datagrid. Can you or anyone help?
Thanks again!
|
|
|
|
|
You don't. You bind it to a DataSet just like you do now with reading the data from SQL. The only difference is you use the DataSet class' ReadXml method to get the data. This is just one of the .ReadXml()[^] method overloads:
Dim newDataSet As New DataSet
newDataSet.ReadXml(filepath)
To save it back out, it's just as easy:
newDataSet.WriteXml(filepath, XmlWriteMode.WriteSchema)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks again!
Sorry to be a pain, but can you help me with the translation? I'm used to using SQL datasets that have tables:
TickersTableAdapter.Fill(Me.DataSet1.Tickers)
TickersTableAdapter.Update(Me.DataSet1.Tickers)
DataSet1.Tables("Tickers").Select(TDataToGet)
Etc.
Following your instructions, I can read the xml dataset file from disk:
Dim TickersDataSet As New DataSet
TickersDataSet.ReadXml("c:\tickers.xml")
But then how to I get it into a format that I can operate on? Can I make that .xml dataset have tables?
|
|
|
|
|
cstrader232 wrote: Can I make that .xml dataset have tables
Yes. You have to define the .XSD files (XML Schema) which will define the tables and their fields.
The code you posted is VB.NET 2005 code. The two TableAdapter statements just retrieve data from an SQL table and places it in a DataSet object, and writes any changes back to the source table.
Which version of VB.NET are you using?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|