|
How to detect an Internet Connection
(Saturday, September 18, 2004)
Found the following interesting discussion in the Newsgroups:
Detecting Internet Connection by:Adam Tibi
| Is there any way to detect Dial-up Internet connection using .NET libraries or do I have to use Win APIs for that?
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | * "Adam Tibi" <atibi@DONTSPAMME.terra.net.lb> scripsit: > Is there any way to detect Dial-up Internet connection using .NET libraries > or do I have to use Win APIs for that?
There is currently no managed way to do that available in the Framework.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Anonymous
| | | Hai Adam,
There is an API to check whether you have the internet connection are not. But i dont' remember it right now. I have used that in some part of my project. I will mail u that.
Sadha Sivam S Malleable Minds Software Pvt Ltd., sadhasivam1981@yahoo.com
| | | Reply: by:Anonymous
| | | Hi Adam,
Check with this api,
'API method to check for the internet connection Public Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Integer, ByVal dwReserved As Integer) As Integer Public Const FLAG_ICC_FORCE_CONNECTION As Short = &H1S
Where it takes the URL you want to check.
Sadha Sivam S Malleable Minds Software Pvt Ltd.,
| | | Reply: by: SamSpade
| | | if lpszUrl is null and the flag is false can this be used to see if there is any connection at all ?? Excuse for butting in!
|
Posted by Xander Zelders

Datagrid loses user entries
Found the following interesting discussion in the Newsgroups:
datagrid loses user entries by:Sean Foley
| I have a MDI parent (basically a menu) and a MDI child (data form with datagrid). When i close the parent and the datagrid has been changed i ask the user if they wish to save changes made in the grid
The save routine that i have on the MDI child accessed via a button on the form saves all data entered including the active cell which is that active control a datagridtextbox
when i call my save routine in the child form from the parent form, i lose the data entered if the user did not move off of the edited row of a datagrid?
I have tried many things and think that it is not activating the lostfocus event of the row, grid or whatever.
Don't know what else to try.
| | | Reply: by:Sean Foley
| | | Basically the currency manager itemschanged event is not kicking off. I used the currency manager to kickoff the positionchanged event.
Need to accomplish clicking to a different datagrid row programmatically? which kicks off both positionchanged and itemchanged events.
ANY HELP GREATLY APPRECIATED
| | | Reply: by:Sean Foley
| | | okay, solution found :)
Dim myBindingManager As BindingManagerBase = BindingContext(myDataSet, "mydatatable")
myBindingManager.SuspendBinding()
myBindingManager.ResumeBinding()
Only problem now, is if the user does not move off the current cell that one entry is lost. At least the row on an insert or on an update with cells is not lost than where the cursor is, is not lost.
|
Posted by Xander Zelders

Variable Conversion
Found the following interesting discussion in the Newsgroups:
Variable Conversion by:Anonymous
| I have a variable named blnAnswer that is a flag in a subprocedure called ValidateEntries() set to true and tripped to false if something fails. When the variable comes out of the subprocedure and everything has passed it is true, but when it gets passed to the calc function it turns to false on the DimblnAnswer as Boolean = ValidateEntries() although the subprocedure is true. We bypassed the assignment and ran the code with just the subroutine. What is going on??
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Please post short, but complete code. Maybe you are creating a new variable and never assign its value to the other variable, but that's hard to say without code.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:yEaH rIgHt
| | | Is ValidateEntries() a Subroutine or a Function?
Tracer wrote: > I have a variable named blnAnswer that is a flag in a subprocedure called ValidateEntries() set to true and tripped to false if something fails. When the variable comes out of the subprocedure and everything has passed it is true, but when it gets passed to the calc function it turns to false on the DimblnAnswer as Boolean = ValidateEntries() although the subprocedure is true. We bypassed the assignment and ran the code with just the subroutine. What is going on??
|
Posted by Xander Zelders

GridColumnStyle that has a Width that 'Expands' to fill?
Found the following interesting discussion in the Newsgroups:
GridColumnStyle that has a Width that 'Expands' to fill? by:Anonymous
| Is it possible to set the first Grid Column to 'autofill' (not the last column, the first). I could calculate the width I guess but the scroll bars are not always there.
thx, troy
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q871q http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q877q
Ken
|
Posted by Xander Zelders

How to split a vb.net application
Found the following interesting discussion in the Newsgroups:
Splitting my vb.net application by:jlpraz@corobori.com (Corobori)
| I developed a vb.net application which has about 90 forms an 70 reports.
I have got the following question: my customer asked me to split up my application in several application. One containing the complete application, and different application each of them containing a different subset of functionalities.
How can I do this ?
Jean-Luc www.corobori.com
| | | Reply: by:Eric Sabine
| | | since you're in so deep already with this one, how about using a logon with password to expose certain parts to some users and expose all to the full functionality users? Eric
| | | Reply: by:jlpraz@corobori.com (Corobori)
| | | Eric,
You're right that's the way I am going to go
jean-luc
| | | Reply: by:Anonymous
| | | Hi Corobori,
Y can't you try by splitting your whole project into many Class Module (Class module can also hold the forms). Group them according to the modules which the user wants. Then built one Windows Application projects which is going to call all the class modules or only some of the modules, depending upon the user requirement.
Sadha Sivam S Malleable Minds Software Pvt Ltd.,
|
Posted by Xander Zelders

How to open a notepad file for viewing in ReadOnly mode.
Found the following interesting discussion in the Newsgroups:
Opening a notepad file for viewing in ReadOnly mode. by:Anonymous
| Hi, To open a notepad file, right now I am using Process.start. But this does not ensure that the file is opened in readonly mode.
How can I make a notepad file open in Readonly mode?
I do not want to change its attributes to Readonly. I do not want to open it in browser or in any other editor except notepad. I do not want to use MFCAppWizard of VC++ or VB to create my own editor. I do not want to paste the text in some richtextbox control.(I am concerned with size. What if the file is real huge and textbox cannot accomodate it all).
Is there any way to open notepad editor without the menubar and ctrl+s option disabled?(So that User cannot perform Save operation).
Any pointers to how this can be achieved will be very useful. Please reply ASAP. I am working in VB.NET.
TIA.
| | | Reply: by:Tom Shelton
| | | Boy, that's a tall order. Basically, I don't think you can accomplish what you want (at least not easily) - especially with the restrictions you've laid down.
Hope you figure something out. -- Tom Shelton [MVP]
| | | Reply: by:Schfooge
| | | I have a suggestion that may work, unless I'm misunderstanding what you're wanting to do. Instead of worrying whether user can alter your text file, create a temporary copy of the text file and open that. Thus, the user can change, save, or do whatever they want to the temp copy without affecting your "real" copy of the text file.
Hope this helps
|
Posted by Xander Zelders

Pages User Permissions
Found the following interesting discussion in the Newsgroups:
Pages User Permissions by:ruca
| hi,
How can I setup the user permissions over some pages of my web application? I want to deny that some users access some of my web pages. How can I do this in code?
At this moment I have a session variable that have False or True value. I get this value from my DB. Then in my Page_Load event I have this:
Sub Page_Load (...) If CBool(Session.Item("bValue")) Then //some code here Else Page.Controls.Clear() Response.Redirect("dcsError.htm", False) End If End Sub
but I think that must be another way to do this -- Programming ASP.NET with VB.NET Thank's (if you try to help me) Hope this help you (if I try to help you) ruca
| | | Reply: by:Jeremy
| | | You don't want to do that, .NET has authentication abilities built in that are quite nice, and easy to use.
See this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-jspmig-authentication.asp HTH, Jeremy
| | | Reply: by:Steve C. Orr [MVP, MCSD]
| | | Forms Authentication is very handy for this kind of thing. It's sufficient for basic needs and can usually be extended for more advanced needs. Here's more info: http://www.dotnetbips.com/displayarticle.aspx?id=9 http://www.4guysfromrolla.com/webtech/121901-1.2.shtml http://www.dotnetbips.com/displayarticle.aspx?id=117
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net Hire top-notch developers at http://www.able-consulting.com
|
Posted by Xander Zelders

How does one control the what is entered in a bound DataGrid control?
Found the following interesting discussion in the Newsgroups:
How does one control the what is entered in a bound DataGrid control? by:acool
| How does one control the what is entered in a bound DataGrid control? ie: I have an nvarchar field bound to a particular colomn in a Datagrid and i want to be able to control (or check what a user enters in that particular column).
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q773q
Ken
|
Posted by Xander Zelders

UNC System.IO
Found the following interesting discussion in the Newsgroups:
UNC System.IO by:Andrew J Durstewitz
| Hi!
I'm having an issue using the System.IO namespace and trying to use File.Exists(myFile) when myFile exists on a mapped drive. I have setup the machine (where the drive is mapped to) to give my computer full access.
Has anyone else run into issues like this? Any ideas on how to resolve this?
Thanks, Andrew J Durstewitz
| | | Reply: by:Sven Groot
| | | What issues? What are the error messages/exceptions that you're seeing? What code is generating the problem?
-- Sven Groot
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | What does the function return? A wrong value? Is an exception thrown? Please be more specific!
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
|
Posted by Xander Zelders

ClassName case sensitive
Found the following interesting discussion in the Newsgroups:
ClassName case sensitive by:Vicenç Masanas
| I had a problem with some webforms and user controls. From time to time when developing a new form or user control and testing I got the following error:
Could not load type 'xml.WebForm1'
I use to fight with this for a while and I allways endend up deleting the form and starting again. Then it worked.
BUT TODAY I FOUND MY PROBLEM!
This error was showing becase on the <@page> or <@control> directive I had an Inherits clause that pointed to a class which was slightly misspelled:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="xml.WebForm1"%>
and in the code behind file I had:
Public Class webForm1 Inherits System.Web.UI.Page ....
Notice the difference in the initial character of the className: just a lowercase or uppercase difference. I've found the same problem with user controls.
I've tried with different projects and I get the same result on all. It's quite easy to reproduce:
create a new web project (defaults with WebForm1.aspx) compile and run ---> it works
change the inherits clause on the <@ page> directive (just upper or lower case, for example to Webform1 compile and run ----> it doesn't work
Why? Please can someone give a reason of this behaviour?
Vicenç
| | | Reply: by:Sven Groot
| | | Name lookup in the .Net Framework is case sensitive. This is reflected in languages such as C#, where 'somename', 'Somename', 'someName' are all different entities. Although Visual Basic as a language is not case sensitive, this is just the Visual Basic compiler abstracting away the case sensitivity of the CLR. The VB compiler takes extra effort to produce IL code where the names do match. So if you declare your class webForm1, but reference it somewhere else as WebForm1, the IL the VB compiler will emit will actually make that reference read webForm1 to have the case match.
Apparently, the @page directive in ASP.NET, which is after all used by all languages, not just VB, does not have this feature. So lookup is case dependant.
-- Sven Groot
|
Posted by Xander Zelders

Tokenizer question
(Wednesday, September 15, 2004)
Found the following interesting discussion in the Newsgroups:
Tokenizer question by:burak.gunay@xpandcorp.com (Burak)
| Hello,
I will start working on a project where we have to parse a string and store the words and the number of times each word appears.
I know you can use the Split function to split a string into words and then I'd have to savethe words and keep a track of how many times each one appears.
Does .NET already have a way to do this?
Thank you,
Burak
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Split and Count ;-).
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Cor Ligthert
| | | Hi Burak,
Yes it is in the simple .Net namespace VS and also in the extended .Net VB namespace.
Split and Split and Count
Cor
| | | Reply: by:Burak Gunay
| | | Hello Cor,
I ran into the same problem that this person did
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=e%23 p4eYlSDHA.2188%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fq%3DLateboun d%2Bassignment%2Bto%2Ba%2Bfield%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUT F-8%26selm%3De%2523p4eYlSDHA.2188%2540TK2MSFTNGP10.phx.gbl%26rnum%3D2
and changed my code based on the suggestions she received.
I am having problem actually incrementing a member of the structure.
Here is my code
---------------------------- Option Strict On
Public Class test Inherits System.Windows.Forms.Form Public Structure countInfo Public word As String Public num As Integer End Structure
Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
Dim y As New ArrayList Dim infolist As New ArrayList Dim strIn, str As String Dim strOut() As String Dim i, index As Integer Dim z1 As countInfo
' string to parse strIn = txtInfo.Text ' parse results strOut = strIn.Split(CChar(" ")) ' save the string the first time ' next time, incement its number For i = 0 To strOut.GetLength(0) - 1 str = CStr(strOut.GetValue(i)) index = y.IndexOf(str) If Not index >= 0 Then y.Add(str) Dim newInfo As countInfo newInfo.word = CStr(str) newInfo.num = 1 infolist.Add(newInfo) Else For Each z1 In infolist If str = z1.word Then ' z1.num gets incremented ' but the actual structure in the ' array does not z1.num += 1 Exit For End If Next
End If Next
' this works fine For Each z In infolist txtOut.AppendText(z.word) txtOut.AppendText(" ") txtOut.AppendText(CStr(z.num)) txtOut.AppendText(Constants.vbNewLine) Next End Sub End Class
--------------
I would appreciate your help.
Thanks ,
Burak
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
| | | Reply: by:Cor Ligthert
| | | Hi Burak,
I did not look but made something I hope this helps?
Cor
Private Sub Y() Dim infolist As New ArrayList Dim info As New countInfo Dim delimStr As String = " ,.:;#" Dim delimiter As Char() = delimStr.ToCharArray() Dim Cor As String = "Hello Cor, I ran into that same problem: that this person did" Dim Burrakstr As String = Cor.Replace(vbCrLf, "#") Dim Burrak() As String = Burrakstr.Split(delimiter) Burrak.Sort(Burrak) Dim count As Integer For Each a As String In Burrak If a <> "" Then If a <> info.word Then If info.word <> "" Then infolist.Add(info) End If info = New countInfo info.word = a info.count = 0 End If info.count += 1 End If Next End Sub Public Class countInfo Public word As String Public count As Integer Public Sub New() End Sub End Class
|
Posted by Xander Zelders

Adding buttons programmatically in visual basic .net
Found the following interesting discussion in the Newsgroups:
Adding buttons programmatically in visual basic .net by:Anonymous
| Hi,
I have a form and I add buttons programmatically in de form_Load function.
Anybody know how implements de function button_click if in the designer mode the button doesn't exists? I write in visual basic .net: mybutton.Click = New EventHandler (AddressOf DetectedAClick)
private Sub DetectedAClick(ByVal sender as object, ByVal e as EventArgs)
I produced an erron in executing mode, its say: An unhandled exception of type "System.InvalidCastException' ocurred in microsoft.visualbasic.dll. Additional information: Specific cast is not valid.
Do you know what is the problem?
Another question:
In a datagrid control is posible programmatically do autosize columns?
Another:
In a listview is possible that when I select a item doesn't view in blue color?
Thanks
Silvia
| | | Reply: by:Armin Zingler
| | | To add an event handler use Addhandler: addhandler mybutton.click, addressof ButtonClick -- Armin
| | | Reply: by:Cor Ligthert
| | | Hi Silvia,
Now I know what you use. :-) > I write in visual basic .net: Sample a simple methode where you do not have to set all
Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim start As Integer = 4 Dim top As Integer = 25 Dim i As Integer Dim nowdate As DateTime = DateTime.Now Dim mybutton(System.DateTime.DaysInMonth _ (nowdate.Year, nowdate.Month)) As Button For i = 0 To System.DateTime.DaysInMonth _ (nowdate.Year, nowdate.Month) - 1 mybutton(i) = New Button mybutton(i).TextAlign = ContentAlignment.MiddleCenter mybutton(i).Width = 40 mybutton(i).Height = 20 mybutton(i).FlatStyle = FlatStyle.Flat mybutton(i).BackColor = Drawing.Color.AntiqueWhite mybutton(i).Location = New System.Drawing.Point(start, top) mybutton(i).Text = (i + 1).ToString mybutton(i).Cursor = Cursors.Hand Me.Controls.Add(mybutton(i)) AddHandler mybutton(i).Click, AddressOf mybutton_Click AddHandler mybutton(i).MouseHover, AddressOf mybutton_Hoover AddHandler mybutton(i).MouseLeave, AddressOf mybutton_Leave start = start + 40 If (i + 1) Mod 5 = 0 Then top = top + 20 start = 4 End If Next End Sub Private Sub mybutton_Click _ (ByVal sender As Object, ByVal e As System.EventArgs) Dim thisbutton As Button = DirectCast(sender, Button) MessageBox.Show("The day is: " & thisbutton.Text) End Sub Private Sub mybutton_Hoover _ (ByVal sender As Object, ByVal e As System.EventArgs) Dim thisbutton As Button = DirectCast(sender, Button) thisbutton.BackColor = Drawing.Color.AliceBlue End Sub Private Sub mybutton_Leave _ (ByVal sender As Object, ByVal e As System.EventArgs) Dim thisbutton As Button = DirectCast(sender, Button) thisbutton.BackColor = Drawing.Color.AntiqueWhite End Sub
Another question: > > In a datagrid control is posible programmatically do autosize columns? The datagrid is to extended to tell that have a look here first. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridtablestyleclasstopic.asp
> Another: > > In a listview is possible that when I select a item doesn't view in blue color?
That I do not know, however I think one of the painters know that.
I hope this helps so far
Cor
| | | Reply: by:Anonymous
| | | Hi Cor,
Thanks, you do help me a lot. :)
Silvia
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | \\Dim btn As New Button() AddHandler btn.Click, AddressOf Me.btn_Click Me.Controls.Add(btn) .. .. .. Private Sub btn_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) MsgBox("Hello World!") End Sub ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
|
Posted by Xander Zelders

convert function to IntPtr
Found the following interesting discussion in the Newsgroups:
convert function to IntPtr by:Anonymous
| Can anyone help me with this one...
I am doing an API call and need to convert a function address to a IntPtr for a callback...
e.g.
RasDial(X,X,X,Pointer to Callback Function,X)
'Pointer to CallBack Function' needs to be of type IntPtr and the actual function to handle the callback is
RasCallBackFunction (byval X as X, byval X as X, byval X as X) Thanks .. Ken
| | | Reply: by:Armin Zingler
| | | Declare it as a Delegate, not as IntPtr.
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingcallbackfunctions.asp
-- Armin
|
Posted by Xander Zelders

Creating objects with New
Found the following interesting discussion in the Newsgroups:
Creating objects via New by:tinman
| Hi...
Are there performance issues related to the way in which the New keyword is used in VB.NET?
For example, is there a difference betwen the following calls:
1. Dim TestString as StringBuilder = New Stringbuilder
2. Dim TestString as New StringBuilder
Thanks...
| | | Reply: by: Gerry O'Brien [MVP]
| | | I don't believe so. Either method will create the new object. It's just a matter of preference. I like the second method because it requires less code.
-- Gerry O'Brien Visual Developer .NET MVP Visual Basic
| | | Reply: by:Armin Zingler
| | | > > Are there performance issues related to the way in which the New > keyword is used > in VB.NET?
No. Armin
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Maybe only at compile time, but not at runtime :-).
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
|
Posted by Xander Zelders

Save record in datagrid while still editing
Found the following interesting discussion in the Newsgroups:
save record in datagrid while still editing by:jaYPee
| i'm wondering how can i update the current record in datagrid while still editing the record. cause i have a checkbox in my datagrid and i want to save the record before changing the value of this checkbox to true to enforce referential integrity. i don't have problem changing the checkbox to true if the record/row in my datagrid is already save. the problem is that if it is the 1st time i add record to this datagrid and then update the checkbox to true.
thanks in advance for any help.
| | | Reply: by:Cor Ligthert
| | | Hi jaYPee,
You can look what currentcellchanged event from the datagrid (and than check in that the columnumber if it is the checkbox) and than the currencymanager.endcurrentedit can do for you.
Not tested just an idea?
Cor
| | | Reply: by:jaYPee
| | | thanks for the immediate reply. here's my code i used. it is working the 2nd time i click the checkbox again. but didn't work the 1st time i click the checkbox
DataGrid1.EndEdit(Nothing, DataGrid1.CurrentRowIndex, False) DataGrid1.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember).EndCurrentEdit()
'save record first before adding course
SqlDataAdapter2.Update(DsStudentCourse1)
|
Posted by Xander Zelders

How to Get info from MDI child
(Tuesday, September 14, 2004)
Found the following interesting discussion in the Newsgroups:
Getting info from MDI child? by:Lars Netzel
| I have a Main Window called frmBase and it has a child window based on frmProject.
I want to save the data I have enetered in frm Project by choose ing save in the menu of frmBase...
How doget the info from the MDI child window? And what happens if I have more than one child, based on frmProject?
best regards /Lars Netzel
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
They are available in the mdichildren collection.
For Each f As Form In Me.MdiChildren If f.GetType Is GetType(Form1) Then Trace.WriteLine(DirectCast(f, Form1).TextBox1.Text) End If Next
Ken
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | Or: 'If TypeOf f Is Form1 Then...'.
;-)
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Lars Netzel
| | | Thankx, it help me!
/Lars
|
Posted by Xander Zelders

About a datagrid row
Found the following interesting discussion in the Newsgroups:
Simple question about datagrid row by:sajid_yusuf@yahoo.com (Sajid)
| Hello!!!
I have a datagrid with multiple rows in it. One way to put any row in edit mode (which displays a pencil mark) is to click on any row and then edit by manually typing in it. But I want to change the values in the rows programmatically. So my question is how can I put any row in edit mode (programmatically) so that I can see the same pencil like mark in the beginning of a row.
Thanks in advance
cheers
SY
| | | Reply: by:Cor Ligthert
| | | Hi Sajid,
When you want to do it programmatically you would do that doing the underlaying datasource, use the dataview and the currencymanager for proper positioning.
I hope this helps, and if you have further questions feel free to do that.
Cor
|
Posted by Xander Zelders

How to Pass Parameters to an Event
Found the following interesting discussion in the Newsgroups:
Passing Parameters to an Event by:Lucas Tam
| Hi all,
What is the best way to pass parameters to an event?
I have a dataadapter.update that fires, and I am capturing the RowUpdated event. How do I pass some custom pamaeters into this event?
Thanks!
-- Lucas Tam (REMOVEnntp@rogers.com)
| | | Reply: by:Anonymous
| | | Hi Lucas Tam,
You can do that in two ways,
1. By inheriting Dataadapter class to a class, and redifining your own event with all the custom parameters which you want and raise the event from the Dataadapter.update event.
2. Have some global variables and set some data, use them in the event.
I hope, it will help you.
With regards,
Sadha Sivam S Malleable Minds Software Pvt Ltd., India
|
Posted by Xander Zelders

How to delete all the contents in a datagrid
Found the following interesting discussion in the Newsgroups:
Delete all of the contents in a datagrid by:Anonymous
| I need to delete all of the contents in a datagrid before re-loading it. Please help.
Thanks.
| | | Reply: by:Anonymous
| | | Hi Bill
What you meant by deleting all the content in the datagrid, is it clearing the datagrid or deleting the records from the database itself.
Sadha Sivam S Malleable Minds Software Pvt Ltd
| | | Reply: by:Cor Ligthert
| | | Hi Bill,
I assume this is a windowforms question. A little bit in other words than Sadha said, clear the datasource (mostly the table)
Cor
| | | Reply: by:adamz5@hotmail.com (adamz5)
| | | Presume the datagrid is bound to the table (test_table in e.g)
test_table.clear()
should clear the table and empty the datagrid
Regards
Adam
| | | Reply: by:Anonymous
| | | If you just want to clear the grid without deleting any data, you can set the datasource to nothing and then restore it:
grdMyGrid.Datasource = Nothing grdMyGrid.Refresh grdMyGrid.Datasource = ? (name of your datasource)
|
Posted by Xander Zelders

Build error for VB.NET but not C#
Found the following interesting discussion in the Newsgroups:
Build error for VB.NET but not C# by:Good Enchiladas
| While building on a class library for an VB.NET object model, I get something similar to the above error message, but not with C#.
The steps to recreate the problem are as follows:
1. Build a RootLevel.dll containing only this code:
using System; namespace RootLevel { public class Root { } }
2. Build a SecondLevel.dll containing a reference to RootLevel.dll and only this code:
using System; namespace SecondLevel { public class Child { private RootLevel.Root _root; public RootLevel.Root Root { get { return _root; } set { _root = value; } } } }
3. Edit the Root class, add a reference to SecondLevel.dll and Re-build the RootLevel.dll. The edited code looks like this:
using System; namespace RootLevel { public class Root { private SecondLevel.Child _child1; //there will be other children public SecondLevel.Child Child1 { get { if (_child1 == null) { _child1 = new SecondLevel.Child(); _child1.Root = this; } return _child1; } } } }
And it builds without an error. Unfortunately, using VB.NET, it doesn't.
1.
Public Class Root End Class
2.
Public Class Child Private _root As RootLevelVB.Root Public Property Root() As RootLevelVB.Root Get Return _root End Get Set(ByVal value As RootLevelVB.Root) _root = value End Set End Property End Class
3.
Public Class Root Private _child1 As SecondLevelVB.Child 'there will be other children Public ReadOnly Property Child1() As SecondLevelVB.Child Get If _child1 Is Nothing Then _child1 = New SecondLevelVB.Child _child1.Root = Me End If Return _child1 End Get End Property End Class
I believe my conversion from VB.NET to C# is 100% equivalent.
The reference to 'Me' in VB.NET step 3 is marked with the following error by the Visual Studio.NET IDE: "Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your project." Obviously, this a simplified example, where children are plugged into the root as needed. The children can be pretty complex and considerably different from each other. Children need to reference the root, and children often need to reference each other.
How can I fix the VB.NET situation. Is this a VB.NET compiler bug or a default C# setting that differs? How do I work around this circular compilation reference situation or whatever is going on here?
Thanks, Kelly
| | | Reply: by:Cor Ligthert
| | | Hi Good,
I think you third class in VB has to be RootLevel and not Root.
I hope this helps?
Cor
| | | Reply: by:Cor Ligthert
| | | Hi Good,
I did not see it, please stay in the original tread.
Cor
|
Posted by Xander Zelders

Comparing datareader result to a string
Found the following interesting discussion in the Newsgroups:
Comparing datareader result to a string by:Anonymous
| I'm a newbie to VB.NET and ASP.NET (as you'll see by my code). However, I'm not able to get a simple process to work. I'm trying to retrieve a record and then check to see if the 'accountstat' column of the DB is set to 'inactive'. I can't, however, get it to compare correctly. Here's the code:
Sub Sign_In(s As Object, e As EventArgs) If IsValid Then Dim conPubs As SqlConnection Dim cmdSelectRecord As SqlCommand Dim dtrUser As SqlDataReader conPubs = New SqlConnection("Server=moses;UID=sa;PWD=webdev;Database=testDB") conPubs.Open() cmdSelectRecord = new SqlCommand("Select * from siteusers where email='" & txtUsername.text & "' and password='"& txtPassword.Text &"'", conPubs) dtrUser = cmdSelectRecord.ExecuteReader()
If dtrUser.Read Then If dtrUser("accountstat") = "inactive" Then txtInvalid.text = "Your account has not been activated. Follow the instructions sent to you via email to activate your account." Else ' Session("uid") = dtrUser("uid") ' Response.Redirect(Session("Referer")) End If Else txtInvalid.text = "Invalid email address and/or password" session("forgotEmail")=txtUsername.text End If dtrUser.Close() conPubs.Close() End If End Sub
| | | Reply: by:William Ryan eMVP
| | | Read is pushing the pointer up one. If you are just checking for one value, use an Output parameter or executescalar. you can use it like SELECT Email from whatever ...then just use Dim s as String = cmd.ExecuteScalar . If the query returned bill@somewhere.net then that's what the string would be. Assuming that you really want a datareader though, get rid of that .Read statement, b/c at most, you'll only be dealing with one row. If you are using the 1.1 framework, replace it with.
If dtrUser.HasRows Then While dr.Read If CType(dtrUser("accountstat"), String) = "inactive" Then txtInvalid.text = "Your account has not been activated. Follow the instructions sent to you via email to activate your account." End While End If
Now,first off, get rid of the name based lookup . It's slow and wasteful. Either use the getordinal method
Dim i as Integer = dtrUser.GetOrdinal("accountstat") and then reference this with dtrUser(i) or just use the index. The index will be the position the field is in the query so the first field will always be 0.
Now, TURN ON OPTION STRICT! This code shouldn't even compile and C# wouldn't let this run. Option Strict Off = Option Slow ON and Option Bugs On
this should actually read dtrUser(0).GetString("accountstat") ' or the index you want to reference instead. Now the logic is still in question but this is the crux of the problem. I'd also use some breakpoints and assertions just to see what's happening... but before you do anything else, Turn On Option Strict... trust me on this.
If you have any specific problems, let me know, we'll get you through it but this should fix it.
Cheers,
Bill
|
Posted by Xander Zelders

Dataviews and constrained datasources?
Found the following interesting discussion in the Newsgroups:
Dataviews and constrained datasources? by:Jerry
| Hi,
I have a couple of datagrids that are based on dataviews. If I filter dataview1 I would like to automatically filter dataview2. I posted something about this before but I think I didn't specifically focus about that I was using dataviews and just datagrids. Ken Tucker was nice enough to share an example using datagrids and relations/constraints from code (thanks ken). I was able to duplicate this example using components and physical datasets/tables, physical connection, etc. I kind of have the idea now about using this like
datagrid2.SetDatabinding(dataset1, "tbl1, tbl1tbl2")
which restricts the 2nd datagrid (based on tbl2) from a selection from the first datagrid (based on tbl1). I guess in the dataviews you use Rowfilter to restric rows. So if I filter dataview1 on some field, I get x number of rows. This gives me some unique row IDS. I then want to filter dataview2 based on this list of ID's. This is not the problem:
dataview2.RowFilter = "ID In (" & strCriteria & ")"
where strCriteria contains the list of IDs which I get from a loop from the rows in dataview1. It just seems a little kludgy. The question is if I can restrict the datatable of dataview2 at the source rather than using RowFilter. Can this be done the same way as a datagrid binding to the relation? Is the dataview limited to the RowFilter or is there a way to constrain the dataview datasource at the source table level?
Thanks, Jerry
| | | Reply: by:Cor Ligthert
| | | Hi Jerry,
It is funny, I was checking something on a question from Bill and now I see I can maybe use that message 3 times in questions in this newsgroup. I give you a part of the text what seems for me intresting for you.
I do not know if it answers your question, however I see a lot of connections to it. (All in a real environment needed Try's are deleted)
\\ Dim Sql As String = "SELECT * from A, B Where " & _ "A.n = B.n AND A.n = 10" Dim Conn As New OleDbConnection(connString) Dim da As New OleDbDataAdapter(Sql, Conn) da.Fill(ds, "A") da.Fill(ds, "B") Conn.Close() 'In this sample the datarelation is in my opinion not needed 'However without that A.n = 10 than it is needed '------------------------------ Dim drlA As New DataRelation _ ("AA", ds.Tables("A").Columns("A.n"), _ ds.Tables("B").Columns("B.n")) ds.Relations.Add(drlA) Dim dv As New DataView(ds.Tables("A")) DataGrid1.DataSource = dv DataGrid1.Expand(-1) ////
'Without datarelation just change dv in ds
See also this to show why the Where and not the Join
http://support.microsoft.com/default.aspx?scid=kb;en-us;318646
I hope this helps?
Cor
| | | Reply: by:Jerry
| | | Hi Cor,
Maybe it's a problem for me, but I am using components (I should probably starting doing it in code). Maybe my approach of restricting records using the dataview.RowFilter method isn't so bad. But one more question if I may:
So I have these 2 tables in my dataset. If I were to declare a dataview in code
Dim dv2 As New DataView(ds.Tables("B"))
Could I do something like this:
Dim dv As New DataView(ds.Tables("Select t1.* From B t1 Join A t2 On t1.ID = t2.ID"))
or something like that?
In the meantime, one other approach was to use a currency manager object on the first dataview and do this:
Dim drView As DataRowView drView = DirectCast(curMgr.Current, DataRowView) dv2.RowFilter = "Id = " & drView("Id").ToString()
This seems less kludgy than looping for ID's but it also only returns 1 ID. My actual goal is to steer away from kludgy :).
Thanks, Jerry
| | | Reply: by:Cor Ligthert
| | | Hi Jerry, > > Dim dv As New DataView(ds.Tables("Select t1.* From B t1 > Join A t2 On t1.ID = t2.ID")) >
No, there is a table.select which does something almost the same as the rowfilter and people think often that it is the same as an SQL select. There is also a table.compute. (I find the rowfilter for the select much nicer and it is faster)
> In the meantime, one other approach was to use a currency > manager object on the first dataview and do this: > > Dim drView As DataRowView > drView = DirectCast(curMgr.Current, DataRowView) > dv2.RowFilter = "Id = " & drView("Id").ToString() > > This seems less kludgy than looping for ID's but it also > only returns 1 ID. My actual goal is to steer away from > kludgy :).
Some find it, I do not, when you put this completly in a loop it is very clear and it can be a very small loop. Do not think that one compound instruction is always faster. (Do not forget to set the datarow.sort before that makes it very fast).
For a loop is not so much needed. The spending time in your system is mostly the drawing on screen.
Cor
|
Posted by Xander Zelders

Windows service not releasing object
Found the following interesting discussion in the Newsgroups:
Windows service not releasing object by:Anonymous
| I've written a Windows Service program that monitors a directory using the FileSystemWatcher class. The monitoring is done on it's own thread. Once a particular files gets added(created) to the directory, the program calls a routine using ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf module.sub)). That routine creates an object of another class. The problem is that classes' Finalize method is not called until the Windows Service is stopped. Does anybody know why that object is not released until the service is stopped and a way for me to ensure that classes' Finalize method gets called?
Here is a summerized version of the code:
1. The OnStart of the service creates a reference to the monitor class and creates a thread for the main routine of the monitor class to run on. 2. The main routine of the monitor class creates a FileSystemWatcher object and performs a do loop waiting for a file to get created using WaitForChanged(WatcherChangeTypes.Created) 3. Once a file is added to the directory, the ThreadPool is used to call a routine in another module using ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf module.subroutine)) 4. That routine creates a reference to let's say X class.
The problem is that X classes' Finalize method never gets called until the Windows Service is stopped. I hope this is somewhat clear and makes sense to someone. Any help is appreciated.
| | | Reply: by:Sven Groot
| | | A class' Finalize method will not be called until the garbage collector runs and decides to collect the object. There is no deterministic way to determine when this will happen. Although it's possible to invoke the GC manually, this is not a good idea. What you want to do is add a Dispose (or Close if that makes more sense for the type of unmanaged resource your class is representing) method to the class and call that yourself when you need the cleanup code to run. Don't forget to call GC.SuppressFinalize from your Dispose method and make sure the class can't be used anymore after calling Dispose (methods of a disposed object must throw an ObjectDisposedException).
Look up the IDisposable interface in the help. This article could also be useful: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcn7/html/vaconUsingConstructorsDestructors.htm
-- Sven Groot
|
Posted by Xander Zelders

How to Shut Down Server
Found the following interesting discussion in the Newsgroups:
Shut Down Server!! by:Michael Persaud
| Hi,
Can any one tell me what to code to shut down a win2003 server given that i have all priveledges.
Thanks MP
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | <URL:http://www.mentalis.org/soft/class.qpx?id=7>
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
|
Posted by Xander Zelders

How to wrap SendMessage
Found the following interesting discussion in the Newsgroups:
How to wrap SendMessage by: SamSpade
| I'd like to define a wrapped SendMessage. Something like:
function zz (TxtHandle as IntPtr, Msg1 as integer, Msg2 as Integer, Struct as Structure, StructSize as integer, StructType as ???) as integer
Dim TmpStruc As IntPtr = Marshal.AllocHGlobal(StructSize)
Marshal.StructureToPtr(Struct, TmpStruc, True)
zz=SendMessage(TxtHandle, Msg1, Msg2, TmpStruc)
Struct = CType(Marshal.PtrToStructure(TmpStruc, GetType(StructType)), StructType)
Marshal.FreeHGlobal(TmpStruc)
end function
I'm not sure about the parameter Struct as Structure. Maybe Object should be the type?
But I have no idea how to pass the type "StructType" for CType
Think this can be done?
Any idea how?
Thanks in advance
| | | Reply: by:Mattias Sjögren
| | | >I'm not sure about the parameter Struct as Structure. Maybe Object should be >the type?
Yes, unless you want to write separate overloads for each structure type (or wait for generics in Whidbey). >But I have no idea how to pass the type "StructType" for CType > >Think this can be done?
If you declare the Struct parameter as Object, you don't need the CType. Let the caller cast it back to the expected type.
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| | | Reply: by: SamSpade
| | | Thank you. Seems to work OK.
|
Posted by Xander Zelders

Passing BackColor Values Between .NET and VB6 applications
Found the following interesting discussion in the Newsgroups:
Passing BackColor Values Between .NET and VB6 applications by:Anonymous
| Hi,
Here's my question first and then some information about what my problem is. Anyone know how or have a function/module/class/whatever to convert from argb to rgb?
We have quite a few vb6 applications that are all called from another vb6 application called the navigator. It's kind of like using explorer. Basically we have two "modes" in the navigator. One is test and one is production. When in test the back color is an ugly orange (just to alert the user they're in test mode) and production is just the typical gray. So when the navigator is told to call an application it writes a bunch of properties to a file for the called application to pick up and apply. One of those properties is backcolor. Well colors must be handled quite differently between vb6 and .net.
In the called application (vb6) the code I use to set backcolor is frmParticipants.BackColor = RetrieveProperty("BackColor"). For the orange test mode the value is 33023. Well in .net I can't specify a color that way. When I send that same orange color property to the called program I use Me.BackColor.ToArgb.ToString and that sends a value of -32768 which the vb6 application doesn't like.
Through some more digging I realized that colors from vb.net are stored as argb and in vb6 it's rgb. I don't really understand what the "a" does in argb other than cause me a headache :-/. I do not want to have to go into each vb6 application and make any changes to convert from argb to rgb so I need to do this on the .net side. Anyone know how or have a function/module/class/whatever to convert from argb to rgb? I guess that's my question in a nutshell.
Thanks,
Jesse
| | | Reply: by:Sven Groot
| | | I don't have VB6 here so I can't check, but from the value you give it appears the order in VB6 is actually BGR, not RGB! This figures because -32768 in two's complement is FFFF8000 hex, but 33023 is 0080FF hex. (on a side note, long live the Windows Calculator)
In any case, the alpha value is transparancy. A value of FF (255) is completely opaque. The only way to solve this is to construct the VB6 number yourself. If you have a variable C of type Color you can do this as follows: Dim BGR as Integer BGR = (C.B << 16) + (C.G << 8) + C.R
The otherway around is of course just reversing the above formula, using bitwise and to get rid of the unnecessary bits where needed. C.B = BGR >> 16 C.G = BGR >> 8 And &hff C.R = BGR And &hff
Hope this helps.
-- Sven Groot
| | | Reply: by:Chris Haas
| | | Even easier, you can go from VB6 to VB.Net using:
System.Drawing.ColorTranslator.FromOle()
It takes an Int32 and return a Color
| | | Reply: by:Anonymous
| | | Thanks Chris. That's the easiest way that I've found. I just did System.Drawing.ColorTranslator.ToOle(Me.BackColor).ToString to convert the .net backcolor to a color that vb6 likes. So now as I convert all of those vb6 apps to .net I'm going to have to do me.backcolor = System.Drawing.ColorTranslator.FromOle(IntColorPassedIn). Then once all my vb6 apps are converted then I can just pass the colors across without any converting.
Jesse
|
Posted by Xander Zelders

Scroll Richtextbox automatically
Found the following interesting discussion in the Newsgroups:
Scroll Richtextbox automatically by:Daniel von Fersen
| Hi,
I have a Funtion
Function addLine(ByVal text As String, ByVal color As Color)
RichTextBox1.SelectionColor = color
RichTextBox1.AppendText("[" + Date.Now.ToShortTimeString + "]: " + text + vbCrLf)
End Function
that adds a line to my Richtextbox! Know i would like the Richtextbox to scroll automatically to the end, so you always see the last lines!
U know how to do this? I would really apperciate that.
Greetz, Daniel
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | See my reply in the German language VB.NET group.
Solution: Call the control's 'Focus' and 'ScrollToCaret' methods.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Anonymous
| | | There is one problem with using the focus - what if you are on another form and do not actually want to show the form with the richtextboxwhen you are appending text, if you do then you cannot use focus, i am looking for another way to do this for the last few hours haven't found any, anybody any ideas.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | I do not see the post's "parent" post, but maybe this code helps:
\\Private Const WM_VSCROLL As Int32 = &H115 Private Const SB_BOTTOM As Int32 = 7
Private Declare Auto Function SendMessage Lib "user32.dll" ( _ ByVal hwnd As IntPtr, _ ByVal wMsg As Int32, _ ByVal wParam As Int32, _ ByVal lParam As Int32 _ ) As Int32
Private Sub AddLine(ByVal Destination As RichTextBox, _ ByVal Text As String) With Destination .AppendText(Text & ControlChars.NewLine) SendMessage(Destination.Handle, WM_VSCROLL, _ SB_BOTTOM, 0) End With End Sub ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:Anonymous
| | | Thanks Herfried, I manged to find a solution already but it looks similar to yours so both may work, anyway mine is It uses Sendmessage also but uses Public Const EM_SCROLL = &HB5 And SendMessage(RichTextBox1.Handle, EM_SCROLL, 1, 0) - this keeps the cursor at the last line which is what I wanted.
|
Posted by Xander Zelders

FileOpen file permission problem
Found the following interesting discussion in the Newsgroups:
FileOpen file permission problem by:Anonymous
| the following fails to write due to a file permission. Setting Everyone to Full-Control works, but I can't figure out the specific accunt/permission.
fileNumber = FreeFile() FileOpen(fileNumber, "C:\INETPUB\WWWROOT\DATA\TEST\TEST0420.TXT", OpenMode.Output) PrintLine(fileNumber, WRITE_DATA.Text) FileClose(fileNumber)
| | | Reply: by:Sven Groot
| | | Judging by the path, I'm guessing you're trying to do this from an ASP.NET application, right? If so, you want to give the ASPNET account write permissions to the location.
Also, I would advice you to move away from using file numbers and their related functions. Using streams is much more elegant:
Dim Writer as New System.IO.StreamWriter("C:\INETPUB\WWWROOT\DATA\TEST\TEST0420.TXT", false) Writer.WriteLine(WRITE_DATA.Text) Writer.Close()
-- Sven Groot
|
Posted by Xander Zelders

TreeView
Found the following interesting discussion in the Newsgroups:
TreeView by:Anonymous
| I am building a project, in which I utilze the TreeView. Here's the explain as what I want to do:
The Root TreeView Node is "Color", Below it I have "Red", "Green", "Yellow" as Child Nodes. Now when I click on "Red", I want a form with Red colored background to popup. The project is not quite this but, it's the same idea :-). Can you help me. Google, leads me to a lot of good articles but non help me out. Please advice.
Colors |_Red |_Green |_Yellow
Please advice and Thanks for your help in advance.
| | | Reply: by:Bernie Yaeger
| | | Hi JSN,
I use a treeview to launch either reports directly or mdi forms which will then generate reports. This is almost exactly what you are looking for. Below is a sample of the code:
Private Sub reporttree_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load
Me.FormBorderStyle = FormBorderStyle.None
' this would make the form purely the designated color, without
' the control or windowstate menus and without a caption, ' drag top, icon, etc.
Me.Height = 728
Me.Width = 360
Dim p As New Drawing2D.GraphicsPath
p.StartFigure()
p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
p.AddLine(40, 0, Me.Width - 40, 0)
p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, _ 40), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
p.CloseFigure()
Me.Region = New Region(p)
Me.BackColor = Color.Thistle
' jsn: above simple rounds the form -----------
TreeView1.HotTracking = True
' jsn: above is required for the mouse click to launch the form/report
Dim node, node2, node3, node4, node5, node4a, node5a _ As TreeNode
node = TreeView1.Nodes.Add("Standard Reports")
node2 = node.Nodes.Add("Sales Reports")
node3 = node.Nodes.Add("Dealer Reports")
node4 = node.Nodes.Add("Financial Reports")
node4a = node4.Nodes.Add("A/R Reports")
node5 = node.Nodes.Add("Miscellaneous Reports")
node5a = node5.Nodes.Add("CMG Audit Reports")
node2.Nodes.Add("Sell-Through Analysis")
node2.Nodes.Add("Insufficient Sales Activity Report")
node2.Nodes.Add("Issue Sales Summary - Selected Titles")
node2.Nodes.Add("Revised Issue Sales Summary By Publisher")
node2.Nodes.Add("Sales By Category Report")
node2.Nodes.Add("Sales Exceed Draw Report")
node2.Nodes.Add("Store Efficiency Report (Hollywood Video)")
node2.Nodes.Add("Weekly POS Sales Report")
node3.Nodes.Add("Dealer History Report")
node3.Nodes.Add("Dealer Penetration Report")
node3.Nodes.Add("Draw Report")
node3.Nodes.Add("Individual Dealer History Report")
node3.Nodes.Add("New Weider Stores")
node3.Nodes.Add("Non-Receipt Report")
node3.Nodes.Add("POS Draw Report")
node3.Nodes.Add("Reshipper Active Store Distribution Report")
node3.Nodes.Add("State / Zip Shipment Summary")
node3.Nodes.Add("Store Location Report")
node3.Nodes.Add("Store Address List By Title")
node4a.Nodes.Add("A/R By IMC Account")
node4a.Nodes.Add("A/R By Publisher")
node4a.Nodes.Add("A/R Detail")
node4a.Nodes.Add("A/R Summary")
node4.Nodes.Add("Invoice Reprints")
node4.Nodes.Add("Publisher Payables Reprints")
node5.Nodes.Add("Class Of Trade Report")
node5.Nodes.Add("Labels - Most Recent Print Order")
node5.Nodes.Add("Price Change Notice")
node5.Nodes.Add("Production Schedule Report")
node5.Nodes.Add("Revenue Analysis")
node5.Nodes.Add("Special County Report")
node5a.Nodes.Add("CMG Dealer Guide")
node5a.Nodes.Add("CMG Universal Dealer Guide")
node5a.Nodes.Add("O/R Distribution Report")
TreeView1.CollapseAll()
node.Expand()
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As Object, _ ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles _ TreeView1.AfterSelect
If glfonload = True Then
glfonload = False
'jsn: I'll explain this below
Exit Sub
End If
Select Case e.Node.Text
Case "Labels - Most Recent Print Order"
Me.Hide()
glfonload = True
gl_browseprintvar = "f:\imcapps\lblm.rpt"
Dim newmdichildb As New reportprinter_viewerparam
newmdichildb.Text = "Labels"
newmdichildb.ShowDialog()
Case "Publisher Payables Reprints"
glfonload = True
Application.DoEvents()
Dim newmdichild As New pubreprints
newmdichild.Text = "Publisher Payables Reprints"
newmdichild.MdiParent = Me.MdiParent
newmdichild.Show()
Case "Invoice Reprints"
glfonload = True
Application.DoEvents()
Dim newmdichild As New invoiceprint
newmdichild.MdiParent = Me.MdiParent
newmdichild.Show()
Case "A/R By IMC Account"
glfonload = True
Application.DoEvents()
Dim newmdichild As New ageingsbyaccount
newmdichild.MdiParent = Me.MdiParent
newmdichild.Show()
' jsn: end select at some point
If glfonload Then
Timer1.Start()
End If
JSN: glfonload triggers a timer that cycles a bit and then does a me.close:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e _ As System.EventArgs) Handles Timer1.Tick
Dim i, j As Integer
For i = 1 To 15000
For j = 1 To 250
Next
Next
Me.Close()
End Sub
The reason for this is that if you close the form too quickly the treeview errors out, as the new form is not yet open. If you have trouble with this let me know and I'll be glad to help.
HTH,
Bernie Yaeger
|
Posted by Xander Zelders

How to Broadcast a message
Found the following interesting discussion in the Newsgroups:
broadcast message by:Edward
| Hello,
I want to create an application that checks in a database for new records and send a message over the network to all clients via a broadcast message (like the MSN messenger). So not a popup window, but a small window near the right bottom corner.
My question is, how can i send broadcast messages to clients like this, or maybe have a small service running on the clients that listen to a service running on the server.
Any help is welcome.
Thanks,
Edward
| | | Reply: by:William Ryan eMVP
| | | You could start a Net Send but I don't think that's what you want. If you want to broadcast a UDP message, here's how you do it. http://www.knowdotnet.com/articles/udpbroadcastmessage.html . you can have each instance of your app listen for the message and respond accordingly.
HTH,
Bill
|
Posted by Xander Zelders

Upgrading or using the Online Resources Tap
Found the following interesting discussion in the Newsgroups:
I cant Ubgrade or use my Online Resources Tap by:Anonymous
| Hi cant use Auto update on my Vb.net and i also cant see the Online Resources page it says i am not online.
Canc Anyone Help me i just bought this programm and already starting to get pissed about it.
| | | Reply: by:Brian Henry
| | | Auto update on vb.net?!
| | | Reply: by:Anonymous
| | | oh made a mistake here its Visual Studio net seems to be a diffrence in that well nvm i post it diffrent area
|
Posted by Xander Zelders

Basic debugging
Found the following interesting discussion in the Newsgroups:
basic debugging question by:Bob
| In code when I'm handling an exception, I'd like to be able to tell the debugger, if it's attached, to break and then navigate to where the exception was thrown, which won't be where I break. Is that possible?
Bob
| | | Reply: by:Les Smith
| | | Bob, I don't know how to do what you are asking, except in an add-in, possibly, but if you just want to know where the line that caused the exception is, do the following:
In the Solution Explorer, right click on the project, click the Properties menu option. In the dialog, click on Configuration Properties, Build, and check the Generate Debugging Information. That will put line numbers in the PDB. When you get an exception, trap the ex as System.Exception, print out (msgbox) ex.ToString and you will get the failing line. You can then Set Next Statement to the offending line to be able to check the status of variables at the time of the failure.
HTH Les Smith http://www.KnowDotNet.com
| | | Reply: by:Bob
| | | Thanks. You're right, an addin is the way to go. Maybe I can force VS.Net to break execution on any exception throw, which is where I usually need to look.
|
Posted by Xander Zelders

| |