Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 

 
How to Refresh ReportDocument (Saturday, October 09, 2004)

Found the following interesting discussion in the Newsgroups:

Refresh ReportDocument
by:teenameenadotnet@yahoo.com (Meena)

Hi every Body,
I am using Crystal Reports with vb.net interacting with front end
every thing fine, I still Have a doubt of the report is refreshing
really or not.

Dim crReportDocument As New
rystalDecisions.CrystalReports.Engine.ReportDocument
Dim strRecodSelectionFormula As String

crReportDocument.Load("Report1.rpt")

''''passing some strings to edit recordselection formulae,

crReportDocument.RecordSelectionFormula = strRecodSelectionFormula
crReportDocument.Refresh()
CrystalReportViewer1.ReportSource = crReportDocument

The above I am doing is refreshing reportdocument and not the report
directly,
Is it refreshing Really.
Early Repliey is greatly appreciated.

Thank you,
Regards
meena.


 Reply:
by:Armin Zingler

 
Does it help to remove and add the reportsource again?

CrystalReportViewer1.ReportSource = Nothing
CrystalReportViewer1.ReportSource = crReportDocument

--
Armin


 Reply:
by:teenameenadotnet@yahoo.com (Meena)

 Hi Armin,
Thank You for ur Sugession,Yes it's defenitely helps me.It kills the
loaded report and reloads again.But I have to consider abt the speed
of it when reloading again.

On the MSDN Documentation its saying the below....

Refresh --- Reloads and displays the report from its original source.

I just wanted to made some changes in database records manually to
check weather the changes are reflecting when refresh method applying
,if it's not updating I will go with the sugession what U have
given.Ofcourse I should have test it before posting my
question.Thanks again for your Reply.

Regards,
Meena.



Posted by Xander Zelders
0 Comments



inconsistent toString behavior

Found the following interesting discussion in the Newsgroups:

inconsistent toString behavior
by:nate-google@spindriftconsulting.com (Nathan R.)

Hi,

I'm seeing something that seems extremely strange to me. All I'm
doing is overriding the toString method in one of my classes, so that
instances will display the way I'd like in Combo boxes and the like.
But instead of calling the overridden method of the subclass, it looks
like Object.toString is being called instead -- toString returns
"MyProjectName.MyClassName".

So that's strange and mysterious, but that's not the end of it. I
found a post on this group (URL
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=uelVmkOjDHA.1688%40TK2MSFTNGP12.phx.gbl&rnum=4&prev=/groups%3Fq%3DtoString%2Bgroup:microsoft.public.dotnet.languages.vb.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dmicrosoft.public.dotnet.languages.vb.*%26selm%3DuelVmkOjDHA.1688%2540TK2MSFTNGP12.phx.gbl%26rnum%3D4)

with a similar problem, and no real resolution. Using this, I reduced
the problem code to the following:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim joe As New Name("joe")
Dim obj As Object = joe
Debug.WriteLine(joe, "Joe")
Debug.WriteLine(obj, "Object")
End Sub
End Class
Public Class Name

Private ReadOnly m_name As String

Public Sub New(ByVal name As String)
m_name = name
End Sub

Public Overrides Function ToString() As String
Return m_name
End Function

End Class

The really strange bit? This works in a new project, but not in the
old. In the old, it gives the old behavior, calling Object.toString
instead. I'm running VB.NET 2002, but the above-referenced post
suggests VB.NET 2003 is equally susceptible to whatever this is.

Any ideas?

Thanks much!

Nathan


 Reply:
by:Armin Zingler

 
I don't understand the problem. I get "Joe" in all cases, also when the
object is added to a combobox, it displays "Joe". This happens in version
2002 and 2003. It's all how I expect it.
--
Armin


 Reply:
by:Nathan Roberts

 
Yes, I'm afraid I didn't expect others to be able to reproduce the
problem, at
least not from the code alone... I think it must be something within
the
project -- either something's become corrupted within the project (??)
or
there's a bad setting somewhere within the project, or some other
project-
specific issue. Because even on my machine, the exact same code behaves
differently in one project than in another.

Thanks for your reply.

Nathan


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
Output in VS.NET 2003:

Joe: joe
Object: joe

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to Launch and sleep multiple applications at the same time.

Found the following interesting discussion in the Newsgroups:

Launching and sleeping multiple applications at the same time.
by:peter@mclinn.com (Peter)

I have written several programs that need to run on different
schedules. The schedules consist of multiple business rules. Until
yesterday I was scheduling most of these applications through the NT
scheduler, but now I can no longer do that. My Administer only will
allow me to have one scheduled task that launches. So my thought was
that I need to create a program that will launch all my applications
at different times during the day. The majority of my programs run
and then exit when complete. When the programs are not running they
sleep. What is the correct way to launch multiple applications. When
I try to do this using a proceedure, the system waits for the 1st
application to stop running prior to starting the next scheduled task.

-Peter


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

\\System.Diagnostics.Process.Start("C:\foo.exe")
///

How did you try to start the applications?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to catch and cancel pressing Tab key

Found the following interesting discussion in the Newsgroups:

How to catch and cancel pressing Tab key ?
by:Anonymous

Is it possible?
Please, don't speak any of TabStop prop.

Thanks in advance.


 Reply:
by:Armin Zingler

 
Why? What's your intention? Prevent the user from changing the focus? He
could also use the mouse. Maybe you can use the Validating event to check
the input and set e.cancel = true if the input is inalid.
--
Armin


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
Have a look at the form's 'Process*' methods in help. You can override
them to capture the tab key.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to Change proportions on objects on Form SizeChange

Found the following interesting discussion in the Newsgroups:

Changin proportions on objects on Form SizeChange
by:Lars Netzel

I have my three datagrids on a form (created in VS design view) and I want
them to grow and have the same space from each other when I maximize or
resize the form they are in.

I know there's a docking property but it's nto enough.. since I have three
grids that ar supposed to be aligned verticaly and if the top one gets a
bigger Height it will grow OVER (or under) the next one... I need therey
space in between to be the same, which means moving the nextone...

any tips?

Right now I'm using, but I asume there are better ways of doing this?

DataGrid1.Width = Me.Width - 100
DataGrid2.Width = Me.Width - 100
DataGrid3.Width = Me.Width - 100

/Lars



 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
Notice the controls' 'Anchor' property.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:Lars Netzel

 Thnkx, I guess I can use a combination then cause the anchor is not really
acting the way I want!

/Lars



Posted by Xander Zelders
0 Comments



DBNULL Error

Found the following interesting discussion in the Newsgroups:

DBNULL Error
by:MadCrazyNewbie

Hey Group,

I keep getting this Error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: "Cannot set Column 'SitesID' to be null. Please use
DBNull instead."

On the following line of code:

dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID") =
Me.cboFaxsDepartment.SelectedValue

Anybody got any ideas or can point me in the right direction?

Many Thanks
MCN


 Reply:
by:Lars Netzel

 From the information you provided I would say that either you have no value
in the Me.cboFaxsDepartment.SelectedValue

check with:
MsgBox(Me.cboFaxsDepartment.SelectedValue

OR... something goes wrong when you save and you don't get a value for the
SitesID column.

Are you allowed to insert Null in "SitesID" column? in that case and if you
WANT TO insert a null value, then you better use DBNull

/Lars


 Reply:
by:Alex Papadimoulis

 If Me.cboFaxsDepartment.SelectedValue Is Nothing Then
'you could also throw an exception or warning box instead of putting in DB
NULL
dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
DbNull.Value
Else
dsFax.Faxs.Rows(Me.BindingContext(dsFax, "Faxs").Position).Item("SitesID")
=
Me.cboFaxsDepartment.SelectedValue
End If



Posted by Xander Zelders
0 Comments



error trapping when binding to custom class

Found the following interesting discussion in the Newsgroups:

error trapping when binding to custom class
by:Anonymous

I have a custom class object which I'd like bound to text boxes etc on the form. All properties of the class look something like this:

<System.ComponentModel.Description("Get/Set value "& _
"associated with Phone column")> _
Public Property Phone() As String
Get
Me.CheckDisposed()
If (m_IsNullPhone = True) Then
Throw New System.Data.StrongTypingException("Cannot "& _
"get value because it is DBNull", Nothing)
End If
Return m_Phone
End Get
Set(ByVal Value As String)
Me.CheckDisposed()
m_Phone = value
m_Changed = True
m_IsNullPhone = False
End Set
End Property

Whe I bind this property to a text box I get this error just after the form load:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in system.dll

Additional information: Property accessor 'Phone' on object 'PPSS.Person' threw the following exception:'Cannot get value because it is DBNull'

There seams to be no obvious way to intercept this error using the Binding object but can only catch it by using a high level error trap. The dataset object seams to handle this situation without raising an error so i guess there must be a way to do this.

Regards


 Reply:
by:Ken Tucker [MVP]

 Hi,

Instead of throwing an error if the phone isn't set why dont you make
the user set it when he creates a new one of your custom classes. That way
you dont have to worry about it being null.

Public Sub New(byval Phone as string)
m_phone = phone
End sub

Ken


 Reply:
by:Anonymous

 I can't do that.
My values come from the database and all my classes support IsPropertyNull (i.e IsPhoneNull) properties and SetPropertyNull (i.e. SetPhoneNull) methods. Strongly typed datasets seam to handle this nicelly but I just don't see how. I think inspection of MSIL is next (not that I wanted to go there).

Thanks for the effort.



Posted by Xander Zelders
0 Comments



How to retrieve multiple records from a access database

Found the following interesting discussion in the Newsgroups:

How to retrieve multiple records from a access database????????
by:neilbennett3_16@hotmail.com (Neil)

Hello everyone,
I am making a program at the moment, and need HELP!!!. I'll start
with the database, my field's r:
fldSku - which a 6 digit number, no more no less (145682)
fldDescription - which is the description of a clothing
fldLabel - Which is the band name of the clothing
and fldPrice. k, what i need to do is, when i search for a SKU (which
might have duplicates) in the db, i want it to return it to a datagrid
on the form, and plus i don't know how to retrieve multiple records
from a db, which will be the same SKU, then put them into a datagrid.

Any help is greatly appreciated.
Thanks.

Neil
NeilBennett3_16@hotmail.com


 Reply:
by:Ken Tucker [MVP]

 Hi,

Put a listbox named listbox1 and a datagrid named datagrid1 on a
windows form. Here is a simple example.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String
Dim conn As OleDb.OleDbConnection
Dim daCustomer As OleDb.OleDbDataAdapter
Dim ds As DataSet

ds = New DataSet()
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"

conn = New OleDb.OleDbConnection(strConn)

daCustomer = New OleDb.OleDbDataAdapter("Select * from Customers",
conn)

ds = New DataSet

daCustomer.Fill(ds, "Customers")

ListBox1.DataSource = ds.Tables("Customers")
ListBox1.DisplayMember = "CustomerID"
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim drv As DataRowView = ListBox1.SelectedValue
Dim stritem As String = drv.Item("CustomerID").ToString
Trace.WriteLine(stritem)

Dim strConn As String
Dim conn As OleDb.OleDbConnection
Dim daOrder As OleDb.OleDbDataAdapter
Dim ds As DataSet

ds = New DataSet
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"

conn = New OleDb.OleDbConnection(strConn)

daOrder = New OleDb.OleDbDataAdapter("Select * from Orders where
CustomerID = '" & stritem & "'", conn)
daOrder.Fill(ds, "Orders")
DataGrid1.DataSource = ds.Tables("Orders")
End Sub

Ken



Posted by Xander Zelders
0 Comments



Custom validation

Found the following interesting discussion in the Newsgroups:

Custom validation
by:Morten

Hi!

I tried to post this in the csharp group but didn't get an answer so I
thought that maybe someone here will know how to do this - just ignore the
fact that the code is csharp and not VB.

I've been experimenting with server side custom validation and I can't make
it work.

I have a text box which I'd like to validate by sending the content to a web
service which will check it and return 0 or 1. I've added a custom validator
control in VS .Net 2003. The code looks like this:

<asp:CustomValidator id="CustomValidator1" runat="server"
ControlToValidate="CVRNummer" ErrorMessage="TEST"></asp:CustomValidator>

By double-clicking the control the follwoing was added in the code-behind
file:

private void CustomValidator1_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
}

I've tried to add all sorts of things to this Sub to make something happen
but so far nothing has worked. My last attempt was this:

private void CustomValidator1_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
Label3.Text = "TEST";
}

which unfortunately didn't give me the expected result. Can someone help me
out here?

Best regards

Morten



 Reply:
by:Cor Ligthert

 Hi Morten,

Did you already asked this in the newsgroup. I know they do not use often
this kind of code, however I think that they now probably more from the
validator when and how it is firing.

ASPNET
<news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet>

Web interface:

<http://communities2.microsoft.com/communities/newsgroups/en-us/?dg=microsof
t.public.dotnet.framework.aspnet>
Cor


 Reply:
by:Morten

 Hi!

I've tried posting to the ASPNET group you suggested.

Thanks for answering

Morten



Posted by Xander Zelders
0 Comments



Datagrid and using order by

Found the following interesting discussion in the Newsgroups:

Datagrid order by
by:Anonymous

Hi,

I have a datagrid with values and when I order by one column and select one row the row selected not is de correct is that the original one row before order.

The code is that:

Dim gTable As New DataTable("Response")

Dim t As New DataGridTableStyle(False)
Dim c As DataGridColumnStyle
gTable = New DataTable("Response")

gTable.Columns.Add("PatientID", System.Type.GetType("System.String"))
gTable.Columns.Add("PatientName", System.Type.GetType("System.String"))

t.MappingName = "Response"

c = New DataGridTextBoxColumn
c.MappingName = "PatientID"
c.HeaderText = "PatientID"
c.Width = 45
t.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "PatientName"
c.HeaderText = "PaientName"
c.Width = 250
t.GridColumnStyles.Add(c)

t.GridColumnStyles.Add(c)
grdResponse.TableStyles.Clear()
grdResponse.TableStyles.Add(t)
grdResponse.DataSource = gTable


For i = ifirst To gWL.FirstChild.ChildNodes.Count - 1
lMatch = gWL.FirstChild.ChildNodes(i)
lRow = gTable.NewRow()
lRow("PatientID") = GetValue("0010", "0020", lMatch)
lRow("PatientName") = GetValue("0010", "0010", lMatch)
Next

' Sort datagrid column PatientName
Dim lDataView As DataView
lDataView = gTable.DefaultView
lDataView.Sort = "PatientName ASC"

And when I select one row:

If grdResponse.CurrentRowIndex >= 0 Then
msgbox(grdResponse.DataSource.rows(grdResponse.CurrentRowIndex).Item(0))

view PatientID incorrect is the patientID before order by a columns patientname ascendent.
Anybody can i help me??

Thanks


 Reply:
by:Cor Ligthert

 Hi Silvia,

I am not sure because I never use the default view, I make the dataview the
datasource, you can try this.

replace the sensentence

grdResponse.DataSource = gTable

for after the creation of the dataview

grdResponse.DataSource = lDataview

I hope this helps?

Cor


 Reply:
by:Anonymous

 Hi Cor,

Thanks, It is OK

Silvia



Posted by Xander Zelders
0 Comments



How to Convert byte(8) array to long

Found the following interesting discussion in the Newsgroups:

Converting byte(8) array to long
by:Anonymous

i have a byte array of length 8 which i need to use as a long in Visual VB .NET
is there any way that i can do this?


 Reply:
by:Armin Zingler

 

Bitconverter.toint64

--
Armin


 Reply:
by:Anonymous

 Perfect thanks



Posted by Xander Zelders
0 Comments



How to write a Windows API Wrapper

Found the following interesting discussion in the Newsgroups:

Win API Wrapper: How to write them?
by:Chris Wagner

I have about 5 to 10 API from a vendor and they don't supply VB warpper for
it. How hard is it to write a wrapper for VB. Is there a sample code just to
write one simple API? Thanks.


 Reply:
by:Ken Tucker [MVP]

 Hi,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconCallingWindowsAPIs.asp

Ken


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconConsumingUnmanagedDLLFunctions.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to Launch "Windows Security" windows from Process.Start

Found the following interesting discussion in the Newsgroups:

Launch "Windows Security" windows from Process.Start
by:Dean Slindee

I would like to provide a menu item that the users can click that launches
the same "Windows Security" window that doing a Ctrl+Alt+Delete launches,
but thru a Process.Start. Is this possible, and what is the name of the
..exe and it's location?

Thanks,
Dean Slindee


 Reply:
by:Neil Knobbe

 Hi Dean

Yes it is very possible to do what you want. The file that you are looking
for is called taskmgr.exe, so all you need to do is something like this in
the Click event of your button

Process.Start("taskmgr.exe")

Hope this helps.

Neil Knobbe
Visual Basic MVP


 Reply:
by:v-phuang@online.microsoft.com (Peter Huang)

 Hi Dean,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to show the same dialog
with when you press Ctrl+Alt+Del.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my experience I think it is not easy to do this, because we may
need to write a customized GINA Dll to achieve our aim.

For more information, see the Platform SDK documentation for Winlogon and
GINA at
http://msdn.microsoft.com/library/en-us/security/security/winlogon_and_gina.
asp.

Can you tell us what do you wants to do about the windows security dialog,
if you wants to lock the workstation, we have API LockWorkStation, and We
can use ExitWindowsEx windows API to shutdown, restart or logoff.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



 Reply:
by:Dean Slindee

 My intent is to give the user a menu item to lock the workstation. Thanks
for the pointer to the LockWorkStation API. I will consult the Knowledge
base articles. Perhaps there is something I can then do in VB.NET.

Thanks,
Dean Slindee


 Reply:
by:v-phuang@online.microsoft.com (Peter Huang)

 Hi Dean,

Here is the simple code snippet to lock the windows.

Declare Function LockWorkStation Lib "user32.dll" () As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
LockWorkStation()
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support



Posted by Xander Zelders
0 Comments



Enumerate and Host Control Panel Applets

Found the following interesting discussion in the Newsgroups:

Enumerate and Host Control Panel Applets
by:yxq

http://www.codeproject.com/csharp/appletengine.asp

Where is the vb.net sample?


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
C# -> VB.NET Converters:

<URL:http://www.aspalliance.com/aldotnet/examples/translate.aspx>
<URL:http://www.kamalpatel.net/ConvertCSharp2VB.aspx>
<URL:http://csharpconverter.claritycon.com/>
<URL:http://www.ragingsmurf.com/vbcsharpconverter.aspx>
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=c622348b-18a9-47d6-8687-979975d5957d>

<URL:http://www.remotesoft.com/>
-> "Octopus"

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to detect the attachment of removable storage

Found the following interesting discussion in the Newsgroups:

VB.NET - Detecting the attachment of removable storage?
by:Max

Not sure exactly how to describe this or if it's even possible, so I'll
do my best and would appreciate some suggestions.

I'm currently working on a service that will allow me to automate some
file and folder manipulations. While this question is not concerning the
primary purpose of the program, I think it would be a nice addition.
What I'd like to be able to do is have the service be able to "detect"
whenever the user attaches some mass storage device (flash drive, usb
hard drives, mp3 players that don't need any soft, some media in card
readers like CF or SD, etc.) and be able to identify it, like by a
serial number or something. Would this be possible through some API
maybe? It's only for Win2k, XP, and 2k3, and all of those all do these
operations very easily and quickly, just a little pop-up from sys tray
to let you know that the device has been identified. How could I monitor
those events, find some information about the device that would separate
it from all others, and then get the drive letter that windows gave it?

Might be a rather complex problem, but like I've said, don't know much
about or how to even begin. If you have any ideas, please let me know.
Thanks.


 Reply:
by:Ken Tucker [MVP]

 Hi,

Create a windows hook to look for the WM_DEVICECHANGE message.
http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/
http://www.dotnet247.com/247reference/msgs/43/217435.aspx

Ken


 Reply:
by:Max

 Would you by any chance have some VB code examples? I did a little bit
of looking around, but most of what I found was in C++ and still nothing
that gets me any closer.

Ken Tucker [MVP] wrote:


 Reply:
by:Cor Ligthert

 Hi Max,

I do not know how far it is possible, however I think you would have a look
first to this management class before you start with API's

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmanagement.asp

I hope this helps?

Cor



Posted by Xander Zelders
0 Comments



How to Use a variable to build the name of a variable for assignment

Found the following interesting discussion in the Newsgroups:

Using a variable to build the name of a variable for assignment
by:Bruce Dumes

Ok, the subject line of this is pretty confusing, I'll admit.

I'm new to dotnet and VB. I've used this kind of construction in Perl a
zillion times over the years.

What I've got is something like this (not my entire code):

<MYCODE>
Sub setVisible(Stage As Integer)

Select Case Stage


Case 2

Panel1.visible = false
Panel2.visible = true
Panel3.visible = false

Case 3

Panel2.visible = false
Panel3.visible = true
Panel4.visible = false

Case 4

Panel3.visible = false
Panel4.visible = true
Panel5.visible = false

Case 5

Panel4.visible = false
Panel5.visible = true
Panel6.visible = false

End Select

End Sub
</MYCODE>

What I'd like is something like this:

<MYBETTERCODE>
Sub setVisible(Stage As Integer)
'If there were an eval, I might do this
eval("Panel" & Stage - 1 & ".visible") = false
eval("Panel" & Stage & ".visible") = true
eval("Panel" & Stage + 1 & ".visible") = false
End Sub
</MYBETTERCODE>

Is there a way to do this in dotnet VB?

Thanks!




 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

\\Private m_MyPanels() As Panel
..
..
..
m_MyPanels = New Panel() {Panel1, Panel2, ..., Paneln}
..
..
..
Private Sub SetVisible(ByVal Stage As Integer)
m_MyPanels(Stage - 1).Visible = False
...
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:Sven Groot

 
Unfortunately no. You could theoretically do something like it using
reflection, but the code would become incredibly complex and convoluted, and
slower as well.

--
Sven Groot

http://unforgiven.bloghorn.com



Posted by Xander Zelders
0 Comments



How to Update a SQL database

Found the following interesting discussion in the Newsgroups:

Updating a SQL database
by:Anonymous

Hello,
I can't get my update command to work...

I've used the sqlDataAdapter wizard to create a dataAdapter sqlDA_CB_LP, and it created the 'UPDATE' code as follows:

Me.sqlDA_CB_LP.UpdateCommand = Me.SqlUpdateCommand4
Me.SqlUpdateCommand4.Connection = Me.SqlConnection1

Me.SqlUpdateCommand4.Parameters.Add(New _
System.Data.SqlClient.SqlParameter("@STR_COMMENT", _
System.Data.SqlDbType.NVarChar, 1073741823, "STR_COMMENT"))


In my sub that populates the form:

cbLP = New SqlCommandBuilder(sqlDA_CB_LP)
dsCBLP1.clear()
sqlDA_CB_LP.fill(dsCBLP1)
dvCB_LP = New Dataview

with dvCB_LP
.table = dsCBLP1.Tables("TDT_CUT_BLOCK_LP")
.RowFilter = "ID_CUT_BLOCK = '" & txtBlockID.Text & "'"
End With

Me.txtLPComm.DataBindings.Add("text", dvCB_LP, "STR_COMMENT")


Then under my "Save" button:

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal _
e As EventArgs) Handles btnSave.Click

Try
sqlDA_CB_LP.Update(DsCBLP1, "TDT_CUT_BLOCK_LP")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

But, it doesn't work...
Any ideas what I'm doing wrong??

Thanks,
Amber


 Reply:
by:William Ryan eMVP

 Hi Amber:
What exactly do you mean when you say it 'doesn't work'? There can be a few
things. The first thing to do is verify that you have changes in your
dataset, if you don't, calling update 10000000 times won't do a thing. So,
right before the Update command, insert this:

Debug.Assert(DsCBLP1.HasChanges)

Now, if you get a big ugly messagebox popping up, the problem is that you
don't have any changes in the DB. You may need to call EndCurrentEdit or
one of a few other things... So verify the HasChanges first and we'll
eliminate things from there.

Next, are you gettting an exception or is it just not updating the changes
in the DB?

Another thing, if you use the COnfiguration wizard, it should gen the logic
for you for the Update/Delete/Insert statements. you don't need a
commandbuilder and you don't want to use it if you already have your logic
in place. When you ran the configuration wizard, did it tell you that it
succesfully created the Update/Insert/Delete commands? If you don't have a
key for instance, it won't work but neither will the CommandBuilder -
although it should throw an exception.

Let me know about these and we'll take it from there.

Cheers,

Bill


 Reply:
by:Anonymous

 Hi Bill,
Thanks for your help :)
I added the "debug.assert()" line, and it did come up with an error...so I guess there is nothing to update.
I did run the wizard, and it did generate all the sql commands.
I've been battling this for a while, and was told I had to add the 'commandbuilder' line...
Does it have anything to do with the fact that I'm using a dataview, of a dataset, then trying to update the dataset?
What I have is a form that has text fields populated (by this dataview) from a SQL database. I'm changing the text in them to trigger a 'change' so the update command will work.
A 'save' button calls the update method.
Any ideas??
Thanks
amber



Posted by Xander Zelders
1 Comments



How to link help with a DLL

Found the following interesting discussion in the Newsgroups:

How to link help with a DLL?
by:Anonymous

I haven't stumbled across how to do this in VB.Net.

VB6 had the HelpContextID to associate a help topic with a specific method.

All the .Net discussions are related to applications with visible interfaces and associating help with controls. In a DLL I need to associate help with a method. How to do this in VB.Net?


 Reply:
by:Marc Butenko

 In the method, put the following code:

Help.ShowHelp(Me, HelpFilePathAndName, HelpNavigator.Topic, HelpTopic)

or

Help.ShowHelp(Me, HelpFilePathAndName, HelpNavigator.Find)

or

Help.ShowHelp(Me, HelpFilePathAndName, HelpNavigator.TableOfConents)

or

Help.ShowHelp(Me, HelpFilePathAndName, HelpNavigator.Index)

Hope that "Helps"


 Reply:
by:Anonymous

 Presumably, I also need to add a dummy form and dummy control to the DLL to act as the parent for the help dialog box



Posted by Xander Zelders
0 Comments



How to convert date to ticks

Found the following interesting discussion in the Newsgroups:

convert date to ticks?
by:hra242@hra.co.santa-cruz.ca-dot-us.no-spam.invalid (sparkle)

Hi,

Does anybody know how to convert date to ticks from a dateTimePicker?
What I'm using now isn't working.

I'm trying to use a dateTimePicker to set an appointment in Outlook
with a reminder. I need this reminder to remind the recipient 14 days
in advance.

I'm having problems with the ReminderMinutesBeforeStart. If I simply
multiply the minutes by the days, the reminder doesn't have the
checkbox checked or it is checked, but with 0 minutes. As if it can't
figure out that many minutes.

I've written some code to do this for me, but with the same results
(checkbox in the reminder set to 0 minutes).

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim oApp As Outlook.Application = New Outlook.Application
Dim lDays As Long
Dim lMinutes As Long

lMinutes = DaysToMinutes(lDays)

' Create a new AppointmentItem.
Dim oAppt As Outlook.AppointmentItem =
oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)

oAppt.Subject = "Parking Permits Will expire in two weeks"
oAppt.Body = "Let Employees with Parking Permits know the
expiration date is two weeks away"
oAppt.Location = "Watsonville"
oAppt.Start = Convert.ToDateTime(dtpExpired.Value)
oAppt.End = Convert.ToDateTime(dtpExpired.Value)
oAppt.ReminderSet = True
oAppt.ReminderMinutesBeforeStart = lMinutes

' Save to Calendar.
oAppt.Save()

' Clean up.
oApp = Nothing
oAppt = Nothing

End Sub

Function DaysToMinutes(ByVal days As Long) As Long
Return days =20160
End Function

End Class

Does anybody know if the TimeStamp would work better for subtracting
days? If so, how do I convert the date to ticks?

Here is a TimeSpan string that could be used to show negative values:
"[-]14:00:00:00", but this is using ticks...

Thanks,



 Reply:
by:Sven Groot

 sparkle wrote:
> Return days =20160

I don't know it this is your problem or just a typo in the post, but that
should obviously not be an equals sign. It would return zero as you
described, since 'days=20160' equals false.

--
Sven Groot

http://unforgiven.bloghorn.com



 Reply:
by:Cor Ligthert

 Hi Sparkle,

Why are you sending such a large piece of code that has nothing to do with
this.
>
> Does anybody know how to convert date to ticks from a dateTimePicker?

Simple questions are eays to answer however when the rest of the text seems
to have no relation with the question you mostly get no answer. Here is a
direct answer on your question where I added 14 days in advance)

Dim InTicksDatePlusFourteen As Long = _
CDate(DateTimePicker1.Text).AddDays(14).Ticks

I hope this helps?

Cor


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

Me.DateTimePicker1.Value.Ticks


--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to Retrieve Mouse Data

Found the following interesting discussion in the Newsgroups:

Retrieving Mouse Data
by:Jay Banks

I'm working on a project that lists a few hundred items in a checked
listbox. The listbox entries are all backed up by a structure, and only
the descriptiong of the structure is shown in the listbox. Here's my
structure:

Public Structure ItemData
Dim Descriptiong As String
Dim Cost As Single
Dim Quantity As Integer
Dim Frequency As Single
Dim UnitType As MeasureUnit
End Structure

The MeasureUnit is a enumeration that details how the item is measured
(lbs, oz, grams, etc).

What I'm looking for when the user checks one of the items in the
listbox, is a way to pop up a textbox using the BringToFront method, so
they can fill in how many of these units they want.

There are two things I need to know. The first is finding out where the
mouse is, in relation to the CheckedListBox's Location, and the second
is which item was just checked.

It might help to know that I'm new to .NET, but I do have 13 years of VB
and 6 (not-all-that-great) years of C++ behind me. The concepts I can
understand... but finding the correct methods and members of the objects
is proving a little difficult for me at the moment.

Thanks for any help,
J.
--
The email address listed is not my real address. Please do not send
valid email to that address.


 Reply:
by:Armin Zingler

 
> There are two things I need to know. The first is finding out where
> the mouse is, in relation to the CheckedListBox's Location,

dim p as point
p = CheckedListBox1.PointToClient(cursor.position)

> and the
> second is which item was just checked.

In the listbox' ItemCheck event, the argument e.index returns the index of
the checked or unchecked item.
--
Armin


 Reply:
by:Jay Banks

 Thanks for the help Armin. It actually helped out a lot. I was in a
bit of a hurry when I wrote this, and what I needed to know was how to
tell if the list item was checked, or unchecked (after the click). I
also needed to know which item was checked, but your help showed me that.

J.



Posted by Xander Zelders
0 Comments



How to change the papersize in code for printing

Found the following interesting discussion in the Newsgroups:

how to change the papersize
by:Anonymous

i want to write a code and make the papersize A4
but this code is wrong what is the true one

PrintDocument1.DefaultPageSettings.papersize=A4


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
\\

<...>.PaperSize = New PaperSize(<Name>, <Width>, <Height>)

///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to remove leading zeros in a text string

Found the following interesting discussion in the Newsgroups:

removeing leading zeros in a text string (not a numeric field)
by:Brian Henry

Say I have a text string like

"0002323235-3434-3545" and I want to remove the leading zeros, would a
regular expression work here? sorry I haven't worked with regex's that much
and still need to get caught up on them :) if so how would you go about
doing that? thanks!


 Reply:
by:Marina

 Check out the TrimStart method of the string class. You pass it a character
array of characters to remove - in this case, the array will have one
character, the "0".


 Reply:
by:Armin Zingler

 
msgbox "0002323235-3434-3545".trimstart("0"c)
--
Armin


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
I would use this code:

\\Dim s As String = "000012"
MsgBox(s.TrimStart("0"c))
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:Brian Henry

 thanks everyone, didn't realize you could trim characters like that



Posted by Xander Zelders
1 Comments



How to Navigate within a dataset

Found the following interesting discussion in the Newsgroups:

Navigating within a dataset
by:Anonymous

I want to navigate to a specific record within a dataset.datatable. Some of my controls are bound to this datatable, and it would be nice to do something like:

me.bindingcontext(MyDataset.MyDatatable).position=MyDataset.MyDatatable.FindByMyKeyField

But since the Position property is an integer, this obviously doesn't work. Instead Ive been looping through the entire table (i.e. :

Me.BindingContext(MyDataset.MyDataTable).Position = 0
While Not Me.BindingContext(MyDataset.MyDataTable).Current("MyKeyField") = keyvalue
Me.BindingContext(MyDataset.MyDataTable).Position = Me.BindingContext(MyDataset.MyDataTable).Position + 1
End While

). This just seems wrong to me. Is there a better way?


 Reply:
by:Cor Ligthert

 Hi PMCguire,

I find it a nice routine you have made. Do not forget that underdeck a
shorter method would almost always do the same as your routine.

You can make it look nicer by first making a currencymanager as this
cma as new directcast(bindingcontext(mydataset.mydatatabble)
,currencymanager)
cma.Position = 0
While Not cma.Current("MyKeyField") = keyvalue
cma.Position += 1
> End While

However I see also no better alternative at the moment.

Cor



Posted by Xander Zelders
0 Comments



How to Extract text from a Word doc

Found the following interesting discussion in the Newsgroups:

Extract text from a Word doc
by:Barry

How can I open a word doc and extract the text as text without any
formatting characters??

--
Barry Fitzgerald


 Reply:
by:Cor Ligthert

 Hi Barry,

Office
http://support.microsoft.com/default.aspx?scid=kb;EN-US;311452

http://msdn.microsoft.com/office/

Pia Download
http://www.microsoft.com/downloads/details.aspx?FamilyID=c41bd61e-3060-4f71-a6b4-01feba508e52&displaylang=en

Have a look at those pages

I think you find it there.

Cor


 Reply:
by:Barry

 Thanks, I think that will help me out enough.

--
Barry Fitzgerald


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
I hope you didn't forget to take a look at the "ready-to-be-copied"
solution I posted ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
Add a reference to the "Microsoft Word 10.0 Object Library"
COM component and use thide code:


\\Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim objWord As Word.ApplicationClass
Dim strText As String
objWord = New Word.Application()
With objWord
.Visible = False
.Documents.Open( _
Application.StartupPath & "\cookies.doc", _
, _
True _
)
.WordBasic.EditSelectAll()
.WordBasic.SetDocumentVar( _
"MyVar", _
.ActiveDocument.ActiveWindow.Selection.Text _
)
strText = .WordBasic.GetDocumentVar("MyVar")
TextBox1.Text = _
InsertNewLineChars(Strings.Left(strText, Len(strText) - 1))
.Documents.Close(0)
.Quit()
End With
End Sub

Private Function InsertNewLineChars( _
ByVal strText As String _
) As String
Dim pos As Integer, l As Integer
pos = 1
Do While pos < Len(strText)
l = Strings.InStr(pos, strText, vbCr)
If l = 0 Then Exit Do
strText = _
Strings.Left(strText, l - 1) & vbCrLf & _
Mid(strText, l + 1)
pos = l + 2
Loop
Return strText
End Function
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zelders
0 Comments



How to Connect to Exchange server 2003 with VB. net

Found the following interesting discussion in the Newsgroups:

Connecting to Exchange server 2003 with VB. net
by:Anonymous

Dear folks,
I created a program that connects to Microsoft outlook to extract email information of users. However I'm interested in doing the same from exchange server, so I can run my program even when my pc is turned off. What is the syntax for connecting to exchange server via VB .net? Any help in that direction would be appreciated.

cheers,

Ranjan


 Reply:
by:Eric Sabine

 POP & SMTP?

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=O20dSwDEEHA.712%40tk2msftngp13.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dpop%2Bsmtp%2Bgroup%253Amicrosoft.public.dotnet.languages.vb.*%26meta%3Dgroup%253Dmicrosoft.public.dotnet.languages.vb.*



Posted by Xander Zelders
0 Comments



Object reference not set to an instance of an object. error

Found the following interesting discussion in the Newsgroups:

adding a menuitem array issue
by:Eric Sabine

I've simplified the code to the following. I'm just overlooking something
very simple I'm sure.

Dim mic() As MenuItem
mic = New MenuItem(3) {}
mic(0) = New MenuItem("a")
mic(0).Index = 1

mic(1) = New MenuItem("b")
mic(1).Index = 2

mic(2) = New MenuItem("c")
mic(2).Index = 3

mic(1).MenuItems.Add(mic(2))

------ error below ------- here I get an "Object reference not set to an
instance of an object." error
myProgramsContextMenu1.MenuItems.AddRange(mic)
What do you think is the cause of the error?

Eric



 Reply:
by:Armin Zingler

 
In the mic array, the item with index=3 does not contain a reference to a
MenuItem.
--
Armin


 Reply:
by:Sven Groot

 
VB.NET is not C# in it's array declarations. The statement "mic = New
MenuItem(3) {}" creates an array of length *4*, that is 0 to 3 *inclusive*.
The error is caused when AddRange tries to add mic(3), which is still
Nothing. You need to change your assignment to "mic = New MenuItem(2) {}".

--
Sven Groot

http://unforgiven.bloghorn.com



 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
'mic(3)' is still 'Nothing'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:Eric Sabine

 D'OH!

Thanks Herfried, Sven, and Armin.

Eric



Posted by Xander Zelders
0 Comments



How to send values from one page to another? (Friday, October 08, 2004)

Found the following interesting discussion in the Newsgroups:

How to send values from one page to another?
by:Miguel Dias Moura

Hello,

i have an ASP.net / VB page with a Script (submitValues) and a Form.

1. The form has 20 input texts and a "Submit" button.
2. The script declares 20 variables. The value of each variable is taken
from each of the 20 input texts.
3. When the button "Submit" is click the variable values are sent to an
email address using AspNetEmail.

As an example, the button code is this one:
<asp:Button ID="submit" runat="server" OnClick="submitValues"
Text="Submit"/>

What i want is to create 2 Pages:
A. Page1.aspx where i put 10 input texts.
B. Page2.aspx where i put the other 10 input texts.

When i click the button in Page1, the form values are sent to Page2.
When i click the button in Page2, the form values of Page1 (received) and
the form values of Page2 (inserted) will be sent by email using the script i
mentioned.

Can you help me out?

Thanks,
Miguel


 Reply:
by:Cor Ligthert

 Hi Miguel,

This is to much you ask in one time in my opinon. However remember that you
never send to a page in asp.net you create a page and receive information
which you can store in a session normaly.

On the other page you can use those variables in the session to fill your
page 2 again or your database.

Some information about it.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/defrrdstat.asp
I hope this helps anyway,

Cor


 Reply:
by:Miguel Dias Moura

 I just found a very good article. Well, at least that's my opinion.

http://www.dotnetbips.com/displayarticle.aspx?id=79

What do you think?
It's quite simple...maybe this helps people because i have received a lot of
complicated solutions.

Miguel


 Reply:
by:Cor Ligthert

 Hi Miguel,

Yes that is a nice simple article, as far as I can see in a glimp, does it
takes the method I told you.

Cor



Posted by Xander Zelders
0 Comments



How to Add data to database and send it also no an email?

Found the following interesting discussion in the Newsgroups:

How to Add data to database and send it also no an email?
by:Miguel Dias Moura

Hello,

i have an ASP.net / VB page with a Script (submitValues) and a Form.

1. The form has 10 input text and a "Submit" button.
2. The script declares 10 variables. The value of each variable is taken
from each of the 10 input texts.
3. When the button "Submit" is click the variable values are sent to an
email address using AspNetEmail.

As an example, the button code is this one:
<asp:Button ID="submit" runat="server" OnClick="submitValues"
Text="Submit"/>

What i want is to add a new record in a database and insert this values in
it. I allready created the dataSet to the database.

So, when the "Submit" button is clicked, the values are inserted in a new
record in the database and are also sent to my email.

Can you help me out?

Thanks,
Miguel


 Reply:
by:Alex Papadimoulis

 Miguel,

You will need to add the values to your dataset, and then use a DataAdapter
to update.

Or, you could always just use a simple command and some paramaters ...

cmd = new SqlCommand("INSERT INTO ... VALUES @name")
cmd.paramaters.add("@name",Name)
cmd.connection = new sqlconnection( ConnectionString )
cmd.connection.open
cmd.executeNonQuery
cmd.connection.close

-- Alex Papadimoulis



Posted by Xander Zelders
0 Comments



Compiling single page in VS.NET

Found the following interesting discussion in the Newsgroups:

Compiling single page in VS.NET
by:SS

Hi,

How can I compile only the page/class that I am currently working on in
VS.NET and not the entire project?.

Thx

Sal


 Reply:
by:Alex Papadimoulis

 Sal,

You can't. A compilation is an assembly of all the classes within your
project, hence the entire project needs to be compiled.

Alex


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
What would you expect the result to be? A DLL? You can create a new
project and only the particular class and compile it, but I doubt that
this makes much sense.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by:Steve McLellan

 Ctrl + F7 works for me; I can't remember if I set that up or it's default.
If it doesn't work go to the Options, find the Keyboard page and pick a
shortcut for Build.Compile.

This certainly works for C# and C++, probably VB too.

Steve



Posted by Xander Zelders
0 Comments



How to autosize a DataGrid

Found the following interesting discussion in the Newsgroups:

Datagrid autosize
by:Anonymous

Hi

It is possible in a datagrid by code do the columns autosize??

Thanks


 Reply:
by:Ken Tucker [MVP]

 Hi,

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q877q

Ken



Posted by Xander Zelders
0 Comments



Using WinForms in WebCustomControls

Found the following interesting discussion in the Newsgroups:

Using WinForms in WebCustomControls
by:Anonymous

I asked this question in another NG and got a less than helpful answer.

In a nutshell, in VB6, I could compile an ActiveX dll that resided on my web server that, when navigated to using IE, would start an application that included Windows Forms that looked and acted just like any other Windows Forms (i.e. ones that are part of a regular .exe application installed locally).

Is this still possible using VB.NET?

I have created a WebCustomControl that opens a Windows Form. It works fine in the IDE, but it does NOT work using IE.

IOW, in the development environment, I select "View in Browser" on my .aspx page, and the application starts and the WinFrom opens. Then, I point my browser to the Web site with the Web page and the application starts, but the WinForm does NOT open. Why not?

TIA


 Reply:
by:Cor Ligthert

 Hi James,

I hope I understand you well, repeating that, you want to open with a
webform a windowsform application on the clients computer.

As far as I know that is not normaly posible with vb.net, I saw some
messages from people who said they did it, however some of them asked than
afterwards why they got security problems on the client's computer.

Do as well not forget that this needs the installation from the Net
framework on the client computer, which is not everywhere done and in some
cases even impossible.

It is a non answer, however I hope it helps anyway?

Cor


 Reply:
by:Anonymous

 Thanks for your reply. I figured the .NET framework would need to be installed. The application is for limited distribution, so I can control that.

The odd thing about VB.NET WebControl projects is that you're allowed to include WinForms in them, but they don't seem to actually work when you distribute the app. This leads me to believe that I'm just doing something wrong, but I can't find any real answers about what it is I'm doing wrong, or whether what I want to do is even possible.

This is very frustrating... >:(



Posted by Xander Zelders
0 Comments



Need to call methods in the base class?

Found the following interesting discussion in the Newsgroups:

Need to call methods in the base class?
by: SamSpade

I implemented Drag Drop in a RichTextbox by adding events to my code.

If I were doing it in C# I would instead override The OnDrag* methods and in
my methods call the base.OnDrag*

In my events I do not call any base (MyBase) methods. Should I be calling
something???
Thanks


 Reply:
by:Armin Zingler

 
> I implemented Drag Drop in a RichTextbox by adding events to my
> code.
>
> If I were doing it in C# I would instead override The OnDrag* methods
> and in my methods call the base.OnDrag*

You can do the same in VB.

> In my events I do not call any base (MyBase) methods. Should I be calling
> something???

No, the event is raised /from/ the base class.
--
Armin


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
In the event handlers -- no. In the 'On*' methods -- yes, if you want
the base class's implementation of the method to be executed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 Reply:
by: SamSpade

 Thanks



Posted by Xander Zelders
0 Comments



Event before deleting a file

Found the following interesting discussion in the Newsgroups:

Event before delete file
by:facicad

I would like to know if as event before delete file exist. My probleme is
with FileSystemWatch, it is only Deleted event, and went I want copy for
bakup my file, the file do not exist :(


 Reply:
by:amoura@online.microsoft.com (Alexandre Moura)

 Personally I don't know of such an event. If storage isn't a problem, you
could theoretically monitor the change event and just make a backup of the
file at that point - later, when Deleted is raised, you'll have a backup to
replace the deleted file.

Hope that helps,
Alex


 Reply:
by:facicad

 Look my probleme. On server, if any user delete files, I would like copy
this file on specific directory, beacause Windows server 2000 can't put any
delete files in trash. For this I can catch raise delete button.


 Reply:
by:Armin Zingler

 
I'd think about a different backup system.
--
Armin



Posted by Xander Zelders
0 Comments



Sendkeys for Ctrl+Alt+Del

Found the following interesting discussion in the Newsgroups:

Sendkeys for Ctrl+Alt+Del?
by:Dean Slindee

Have tried, but does nothing:
SendKeys.Send("^%({DELETE})")

Thanks,
Dean Slindee


 Reply:
by:Les Smith

 SendKeys will be consumed by the active application. Unless you have done
something to cause your app to not be the active app, your own app is
probably consuming the keys. The ExitWindowsEx API can be used to shutdown,
reboot, or logoff, but users could get irate about this happening
automatically.

Les Smith
http://www.knowdotnet.com



Posted by Xander Zelders
0 Comments



PixelsToTwipsX()

Found the following interesting discussion in the Newsgroups:

PixelsToTwipsX()
by:Anonymous

In VB6 we have function PixelsToTwipsX(), what's the equivalent in VB .NET? Thanks.


 Reply:
by:Ken Tucker [MVP]

 Hi,

http://p2p.wrox.com/archive/pro_windows_forms/2003-02/6.asp

Ken


 Reply:
by:Sven Groot

 
Nothing, because there are no twips in VB.NET. It only supports pixels.

--
Sven Groot


 Reply:
by:Armin Zingler

 
There are no twips anymore, but assuming 1 twip is still 1/1440 inch, the
formula

pixels / g.dpix * 1440

converts pixels to twips, where 'g' is a graphics object. It's available in
OnPaint or the Paint event from the argument e.graphics. Outside these
procedures call thecontrol.creategraphics to get a graphis object (and call
it's dispose method after usage).
--
Armin


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
Just FMI: Why do you need that?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Posted by Xander Zeld