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





How to add menu items into menu control programatically (Thursday, December 16, 2004)

Found the following interesting discussion in the Newsgroups:

How to add menu items into menu control programatically
by:Anonymous

Hi,

I'd like to get a sample codes to add some menu items into menu control programatically.

Thanks in advance.


 Reply:
by:Eric Lemmon

 Hi Li,

Here is a basic example. Create a new VB.NET Windows form application, and
add a MainMenu control to Form1. Then add the following code:
___________________________________________________________

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

Dim myItem As New MenuItem

' Create "File" menu.
myItem.Text = "&File"
MainMenu1.MenuItems.Add(myItem)

myItem = New MenuItem
myItem.Text = "&New"
myItem.Shortcut = Shortcut.CtrlN
MainMenu1.MenuItems(0).MenuItems.Add(myItem)

myItem = New MenuItem
myItem.Text = "-"
MainMenu1.MenuItems(0).MenuItems.Add(myItem)

myItem = New MenuItem
myItem.Text = "E&xit"
MainMenu1.MenuItems(0).MenuItems.Add(myItem)

' Create "Help" menu.
myItem = New MenuItem
myItem.Text = "&Help"
MainMenu1.MenuItems.Add(myItem)

myItem = New MenuItem
myItem.Text = "&Contents"
MainMenu1.MenuItems(1).MenuItems.Add(myItem)

myItem = New MenuItem
myItem.Text = "&About"
MainMenu1.MenuItems(1).MenuItems.Add(myItem)

Dim i As Integer
Dim item As MenuItem
Dim handler As New EventHandler(AddressOf MenuClickHandler)

' Loop through all 0-level items. (These usually do not need handlers.)
For i = 0 To MainMenu1.MenuItems.Count - 1

' Add the handler to each 1-level menu items.
For Each item In MainMenu1.MenuItems(i).MenuItems
AddHandler item.Click, handler
Next
Next

End Sub

Private Sub MenuClickHandler(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MessageBox.Show("You clicked " & DirectCast(sender,
MenuItem).Text.Replace("&", ""), "Menu Click Handler")
End Sub

___________________________________________________________

Also, if you are adding MenuItems to an owner-drawn menu, you will have to
reinitialize the MainMenu control. Otherwise, you will lose your custom
icons, fonts, etc.

Does this help?

Take care,

Eric


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

 * "=?Utf-8?B?TGkgUGFuZw==?=" <anonymous@discussions.microsoft.com> scripsit:
> I'd like to get a sample codes to add some menu items into menu control programatically.

In addition to Eric's reply: Have a look at your form's 'Sub
InitializeComponent' to see how this is done for menus defined in the
designer.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Sharing Data between forms - strong typed

Found the following interesting discussion in the Newsgroups:

Sharing Data between forms - strong typed
by:Chris Thunell

I have 2 forms, on 1 form i use the wizards to create a strong typed dataset
with tables from an SQL database... and from that i can do stuff like:
me.daEmployee.fill(me.dataset11.tblEmployee) plus some 3rd party controls
can see it the datatables etc etc.

Is there anyway when i open the second form that this information that has
already been loaded into my in-memory dataset be available on all my other
forms... and still be strong typed. (i think i'm using "strong typed"
wording correctly)

I'm in Vstudio2003 and this is a windows forms project.
Any help would be greatly appreciated!
Chris



 Reply:
by:William Ryan eMVP

 In order for it to be strongly typed, you need to use a Strongly Typed
DataSet. This part seems taken care of. What you should do is stick the
DataSet in a Module or Create it as a Shared Property of a class. Then you
can reference it from anywhere. Say you have a class with a Public Shared
Property of type YourStrongTypedDataset and the class is named DataHolder
and the property is MyDataSet.

In form1 you could reference it by DataHolder.MyDataSet. the same goes for
form2 , form3 or any other object . BC its shared (or static in C#) you
don't declare an instance of it, you just reference it directly. Also,
since you are in vb you could just create a module and reference it from
anywhere as MyDataSet although I think adding the prefix avoids possible
naming collisions and is clearer.

When the app loads you should first load this dataset and set the property.
Thereafter, say you have 3 tables and table 1 had 200 rows. Anywhere you
reference DataHolder.MyDataSet, if you check tables.count you'll see 3. You
can check DataHolder.MyDataSet.StronglyTypedTableName.Rows.Count and you'd
get 100(assuming that table was the table I first mentioned.

You may want to create a TypedDataSet by adding it to your project so it's
its own class and that way you could reuse it later on if need be but that's
a side issue basically unrelated.

If you use the Desginer to build it, it'll be strongly typed so you can
refernce it DataSetName.ActualTableName and ActualTableName will appear in
intellisense (proving the strong typing) as opposed to having the reference
Tabes(0) or Tables("NameYouGaveIt").

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/


 Reply:
by:Cor Ligthert

 Hi Chris,

That strongly typed dataset is a class that you can see when you set show
all files in your solution explorer (it is beneath the XDS). Because it is a
seperate class it is usable for all classes. However you have to look in
form1 how to use it.

I hope this helps.

Cor


 Reply:
by:jcfiala523@hotmail.com (John Fiala)

 
Well, if your dataset is a property or a public variable in form1,
then all form2 needs is a reference to Form1.

Alternately, you could always pass the dataset into form2 using a
property or method on Form2.

Note that if the dataset is in a Shared property of form1, then form2
doesn't need to have a reference to Form1 - but be careful with the
shared property's lifecycle. (Note that a Shared New constructor is
only called the first time an object of that class is created, which
is awful helpful for dealing with shared data.)

John Fiala
jcfiala523-at-hotmail.com
http://www.livejournal.com/users/fiala_tech/



Posted by Xander Zelders
0 Comments



Backgroundimage auto-repeating ?

Found the following interesting discussion in the Newsgroups:

backgroundimage auto-repeating ?
by:Anonymous

hi, I have a label on wich I set a backgroundimage. I see the image is auto repeating. Is there a way to have it strech or anything else ?

thanks


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

 * =?Utf-8?B?UGx1bWVQcm9n?= <anonymous@discussions.microsoft.com> scripsit:
> hi, I have a label on wich I set a backgroundimage. I see the image is auto repeating. Is there a way to have it strech or anything else ?

Override the control's 'OnPaint' method and draw the background yourself.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Resource Files

Found the following interesting discussion in the Newsgroups:

Resource Files
by:brian

Thanks to this group my previous quesion directed me to
using a resource file. But now I would appreciate some
help using a resouce file.

I have the resouce file loaded and know I can get at my
file using:
Reflection.Assembly.GetExecutingAssembly
().GetManifestResourceStream("MyApp.RSYNC.EXE")

My embedded file is an EXE file. I need to run the
embedded EXE in a shell command.

Can someone help me with whatever steps I need to proceed
with?

Thanks


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

 * "brian" <bshannon@lbrspec.com> scripsit:
[...]

Double post!

--
Herfried K. Wagner [MVP]


 Reply:
by:Cor Ligthert

 Hi Herfried,

Will you be so kind to set that as I do in the subject next time as well,
than I (and i gues others) do not look at it.

Now I was looking at your answer.

Thank you in advance.

Cor


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

 
I don't do that because it will cause some newsreaders display posts
in a wrong order ;-).

> Now I was looking at your answer.

;-)

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Disabling the right click context menu (revisited)

Found the following interesting discussion in the Newsgroups:

Disabling the right click context menu (revisited)
by:Robert

I have downloaded the demo from MS. There is this code in the control:

' Enable or disable IE's context menu? This allows the parent host
' to render its own.
Public Property BrowserContextMenu() As Boolean
Get
BrowserContextMenu = enableCtxMenu
End Get
Set(ByVal Value As Boolean)
' Disable it. Note that we'll need to do this for each
' page navigation, as the event sink is specific to an
' instance of MSHTML.
If (True = Value) Then
DisableContextMenu()
Else
EnableContextMenu()
End If
enableCtxMenu = Value
End Set
End Property

What do I set to make this disable the context menu? This is literally the
last thing I need to finish the application.

Robert


 Reply:
by:Charles Law

 Hi Robert

I gave you the answer the first time you asked. Have you not tried it?

Charles


 Reply:
by:Robert

 
I am sorry. Ugh! I thought your post was another and have been trying to
implement that one! Let me revisit yours and see if I can use that.

Robert


 Reply:
by:Robert

 
"Charles Law" <blank@nowhere.com> wrote in message
news:%23pGxh6yQEHA.3140@TK2MSFTNGP11.phx.gbl...
<snip>

Dude it worked! Thanks a bunch!



Posted by Xander Zelders
0 Comments



.NET Configuration for Remote App Deployment

Found the following interesting discussion in the Newsgroups:

.NET Configuration for Remote App Deployment
by:Derek Martin

I did an Enterprise Policy based on the Hash of the exe file and created a
deployment package. It appears to work for users on the local machine's
power users group, but not for other users (as most users will not be a
power user)...the enterprise level on those machines is read only. This is
happening if the policy directive msi file is being run by that user. Is
there a way around that, ie, run it at login and it will get applied?

Thanks,
Derek



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

 
If you don't get an answer here, post to a more general .NET Framework
group. Your question doesn't seem to be related to the VB.NET
programming language.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Network Connectivity

Found the following interesting discussion in the Newsgroups:

Network Connectivity
by:Jerry Camel

In VB .Net, is there a quick and easy way to determine if the network cable
is unplugged? Without having to wait for a network access timeout? Thanks.

Jerry


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

 
Maybe it's possible to translate this sample, but I am not sure if it
will fit your needs:

<URL:http://www.vbip.com/wininet/wininet_connection_01.asp>

--
Herfried K. Wagner [MVP]


 Reply:
by:Jerry Camel

 Am I missing something...? This seems to determine Internedt connectivity
(online/offline state) but not sure how to use it to determine if there's a
network cable plugged into the adapter or not...




Posted by Xander Zelders
0 Comments



VB.NET CF query remote SQL server.

Found the following interesting discussion in the Newsgroups:

VB.NET CF query remote SQL server.
by:Anonymous

Im new to the VB.NET stuff but I am looking for a way to query a remote SQL database from a pocket PC application. I have done this in the past with VB6 in wondows using data environment disigners but I dont believe that this is supported with the compact framework.

Any help or sample code would be great!


 Reply:
by:Cor Ligthert

 Hi Leo,

Do you know that there is a newsgroup

microsoft.public.framework.compactframework

Pretty active.

Cor


 Reply:
by:William Ryan eMVP

 You just need to add a reference to the SqlClient dll and then add IMports
System.Data.SqlClient namespace (technically you don't have to do this last
step but it will make life easier).Basically just add this reference, build
your connection string and off you go, I can't think of any differences
between full SQL Server and accessing it on the CF (although Sql Server CE
has a bunch of differences).

If you head over to devbuzz, we have two CF forums (one for VB.NET
http://forums.devbuzz.com/%25NET_Compact_Framework_%2D_VB%25NET/forumid_20/tt.htm)
and one for C#
http://forums.devbuzz.com/%25NET_Compact_Framework_forum_for_C%23/forumid_43/tt.htm
and we also have a Sql Server CE forum
http://forums.devbuzz.com/SQL_Server_for_CE_Forum/forumid_4/tt.htm if you
are interested in using CE. After you build add the reference, it's almost
identical to using SQL Server on the desktop although you probably will want
to specify the permissions. Dan Fergus (author of The Definitive Guide to
the Compact Framework) and Rob Tiffany author of Sql Server CE and the
compact framework (two must have books) both actively participate there and
we have a bunch of Cf mvps' as moderators and authors and we all help out
on the forums.

www.opennetcf.org is also a site that you don't want to miss. It's the best
CF site on the web and although not focued to sql Server and SqlClient,
there's a lot of discussion on it and there's a ton of knowledge. If you
are going to do any CF development, Opennetcf is Definitely the best
resource there is and something that will make your life much easier.
Casey Chesnut also has a bunch of great content at www.brains-n-brawn.com
and he discusses SQL Server, CF stuff, Web Services and much more. It will
be helpful too.
HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/



Posted by Xander Zelders
0 Comments



Dynamically Creating Objects

Found the following interesting discussion in the Newsgroups:

Dynamically Creating Objects
by:chimsuru@hotmail.com (chris)

I know I've asked this before, but I didn't really get an answer and I
bet it's because I didn't explain myself very well. Here goes again.

I have this code:

Dim arrData(intNoOfRows, intNoOfColumns) As Object

Dim intR As Integer

For intC As Integer = 0 To intNoOfColumns - 1
arrData(intR, intC) = ds.Tables(0).Columns.Item
(intC).ColumnName

For intR = 0 To intNoOfRows - 1
arrData(intR, intC) =
ds.Tables(0).Rows(intR).Item(intC)
Next
Next
What I want to do instead is:

Dynamically create the required amount of arrData objects, by
incrementing them by one. i.e. pseudo code:

Dim arrData(inX)(intNoOfRows, intNoOfColumns) As Object

Where intX will be the incrementation that will give me the following
type output:

arrData1
arrData2...etc.

Any Ideas?

Thanks


 Reply:
by:Cor Ligthert

 Hi Chris,

In my opinion do you not want to dynamicly creating objects, however
creating mnemonics at run time.

However what is the difference between your wish and this.

Dim arrData(inXNoOf tables, intNoOfRows, intNoOfColumns) As Object

arrData(1)
arrData(2)...etc.

In my opinion are you now creating dynamicly objects in runtime.
When I would show it with an arraylist in a sample you would see that the
reference to the object is added.

Cor



Posted by Xander Zelders
0 Comments



Overriding .Enabled

Found the following interesting discussion in the Newsgroups:

Overriding .Enabled
by:Phill. W

Here's a knotty little problem.

I have some nasty little controls that needs to behave in a non-
windows-Standard way - don't ask why; it's a large application being
converted from some [much] older code and my users are adamant
that this behaviour mustn't change.

Specifically, I want to be able to set

myControl.Enabled = False

and, instead of the controls /actually/ being disabled, I want them to
/recolour/ themselves so that they /look/ disabled, but still respond to
Mouse events, can be copied from, and such like. (I realise the
ReadOnly property is going to be involved, here, but I don't think it
will do the whole job).

Adding to the complication; I thought I'd derive all of these controls
from a single ancestor UserControl and have that ancestor implement
an Interface containing the Enabled property (among other things), as in

Public Interface ITypeable
. . .
Property Enabled() as Boolean
. . .

Public Class Wrapper
Inherits UserControl
Implements ITypeable
. . .
Public Property Enabled() as Boolean _
Implements ITypeable.Enabled

And herein lies my problem.

The Enabled property already exists in UserControl, so when I try to
implement the Interface property, VB (2003) gets quite upset that the
specifiers or signatures on the Interface and Property don't match.
I've tried overloading, overriding, shadowing, and just about every
other modifier I can find on the Property and even overriding the
OnEnabledChanged routine, but I seem to be on a losing streak here.

Any Suggestions?

TIA,
Phill W.

I have a control that I don't want disabled when I set .Enabled = False,
when my code says
..Enabled = False
I have an application that uses UserConrols to


 Reply:
by:yEaH rIgHt

 Public Interface ITypeable
Property Enabled() As Boolean
End Interface

Public Class Wrapper
Inherits Windows.Forms.UserControl
Implements ITypeable

Public Shadows Property Enabled() As Boolean Implements
ITypeable.Enabled
Get

End Get
Set(ByVal Value As Boolean)

End Set
End Property

End Class


 Reply:
by:Jay B. Harlow [MVP - Outlook]

 Phill,
Do you need to use Enabled specifically to implement the ITypeable.Enabled
property?

Have you consider naming Enabled, something other then Enabled?

Are you attempting to replace how UserControl.Enabled itself operates? Or
should UserControl.Enabled do what it normally does, while Wrapper.Enabled
does what you want?
The easiest route may be to use a different name for your Enabled property,
and ensure that UserControl.Enabled is "not touched", except possible in the

> Specifically, I want to be able to set
>
myControl.MyEnabled = False

Otherwise I suspect you will need some clever (fragile?) overloading,
shadowing, overriding, of the property & OnEnabledChanged method (you
probably need to use a combination of things that it sounds like you tried
individually).

Hope this helps
Jay


 Reply:
by:Phill. W

 "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:%23OgJvt3QEHA.904@TK2MSFTNGP12.phx.gbl...
> Do you need to use Enabled specifically to implement the
> ITypeable.Enabled property?

Ideally, yes.

> Have you consider naming Enabled, something other then Enabled?

Yes - regretably this control will be used by other Developers who
may not appreciate the difference and will cause the eventual Users
considerable confusion :-(

> Are you attempting to replace how UserControl.Enabled itself
> operates? Or should UserControl.Enabled do what it normally
> does, while Wrapper.Enabled does what you want?

Using Wrapper.Enabled is ideally what I'm after, but I need to have
similar behaviours in a number of controls - some are UserControls,
some direct derivatives of, for example, Button. The only way I
know of doing that is with an Interface, but you have to define the
property in order to Implement it, and that's where Studio gets upset.

I think the confusion is that my Wrapper class has both an Enabled
property of its own and my Shadow Enabled property, taken from
my Interface so, if I say

Me.Enabled = whatever

will VB assume I want the inherent property rather than my Shadow?

Regards,
Phill W.



 Reply:
by:Jay B. Harlow [MVP - Outlook]

 Phill,
> I think the confusion is that my Wrapper class has both an Enabled
> property of its own and my Shadow Enabled property, taken from
> my Interface so, if I say

There's the rub, and the reason (the two distinct Enabled properties) I am
suggesting you avoid this. ;-)

> Me.Enabled = whatever

Read very carefully what Shadows does for you. As Shadows is partially how
you will need to get this to work!

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

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

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

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

Shadows BREAKS polymorphism, most of the time you want polymorphism, I
normally only use Shadows to "protected the definition of my class members"
as the first link states. It is unlikely that I would start a new design,
such as this one, that relied on Shadowing! In other words Enabled means
Enabled, in both the derived classes & base class. It does not/should not
mean Enabled in the Control and readonly/something else hybrid in the
derived classes. It can however mean Enabled in the Control, while meaning
Enabled+ in the derived class. Normally the designers of the base class mark
the member (property) as Overridable in the base class to allow you to
define Enabled+ in the derived classes...
When you Shadow the Enabled property, if you refer to Enabled via a base
class you will get the base class's Enabled, if you refer to Enabled via the
derived class you will get the derived class's Enabled.

Public Class Wrapper
Inherits Control ' any control: Button, UserControl, etc...
Public Shadows Property Enabled As Boolean
...

Public
End Class

Dim wrapper As New Wrapper

wrapper.Enabled = True ' will change Wrapper.Enabled

Dim base As Control = wrapper
base.Enabled = True ' will change Control.Enabled, not Wrapper.Enabled
which is probably desired.

' within Wrapper
Me.Enabled = True ' will change Wrapper.Enabled

MyBase.Enabled = True ' will change Control.Enabled

> > Are you attempting to replace how UserControl.Enabled itself
> > operates? Or should UserControl.Enabled do what it normally
> > does, while Wrapper.Enabled does what you want?
>
> Using Wrapper.Enabled is ideally what I'm after, but I need to have
> similar behaviours in a number of controls - some are UserControls,
You did not really answer this question. Should Control.Enabled only do what
Control.Enabled currently does, or should it behave as your new
Wrapper.Enabled property?

Are you using the Interface polymorphically? (do you use the interface as a
parameter to other methods?) If you aren't using the interface
polymorphically I don't know if I would keep it, of course if you want to
have the set of methods in all your classes its handy to keep, I would need
to have a better idea of what is really in the interface to decide. Part of
the point here is that Control already has Enabled, do you really need
Enabled in the Interface...

Anyway I would approach the solution something like:

Public Interface ITypeable

Property Enabled() As Boolean

End Interface

Public Class Wrapper
Inherits UserControl
Implements ITypeable

Private Property ITypeable_Enabled() As Boolean Implements
ITypeable.Enabled
Get
Return Enabled
End Get
Set(ByVal value As Boolean)
Enabled = value
End Set
End Property

Protected Overrides Sub OnEnabledChanged(ByVal e As
System.EventArgs)
MyBase.OnEnabledChanged(e)
' do the logic for Enabled changing
End Sub

End Class

This gives you Enabled in the Interface, it gives Wrapper Enabled+, it
allows Enabled to continue to be Enabled.

If you don't want Enabled+ (IMHO bad idea) you can try something like:

Public Class Wrapper
Inherits UserControl
Implements ITypeable

Public Shadows Property Enabled() As Boolean Implements
ITypeable.Enabled
Get

End Get
Set(ByVal value As Boolean)

End Set
End Property
Protected Overrides Sub OnEnabledChanged(ByVal e As
System.EventArgs)
MyBase.OnEnabledChanged(e)
If MyBase.Enabled Then
' do something based on Control.Enabled
ElseIf Me.Enabled Then
' do something based on Wrapper.Enabled
End If
End Sub

End Class

Hope this helps
Jay



Posted by Xander Zelders
0 Comments



Crystal Issue

Found the following interesting discussion in the Newsgroups:

Crystal Issue
by:CJ Taylor

Hey everyone,

I know there is an online Crystal book floating around here somehwere, lost
the link. I want to insert an image into a pictureObject at runtime from my
application. Using Crystal 9. anyone know how I can do this (just by
loading the .rpt file).

Thanks
CJ


 Reply:
by:Peter van der Goes

 

Here you go :-)

http://www.crystalreportsbook.com/index.asp

Hope this helps.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.


 Reply:
by:CJ Taylor

 Hmm... sadly information not there I was looking for. Thanks though!


 Reply:
by:CJ Taylor

 Ok. So I sort of found the solution to the problem. Crystal just doesn't
have this possiblity unless the report is embedded in the app. And even
THEN its not really that easy to do.

http://www.kenhamady.com/news0207.html

Here's a link that shows a work around if anyone is interested..

-CJ



Posted by Xander Zelders
0 Comments



String.Replace question

Found the following interesting discussion in the Newsgroups:

String.Replace question
by:Craig Buchanan

If I have a string variable, is there a way to get the Replace method to
work on *its* contents, without having to dimenstion a second variable?
Something like:

Dim MyTest as String = "<hello/>"
MyTest.Replace("<", "<")
MyTest.Replace(">", ">")

'MyTest now equals "<hello>"

This code doesn't work the way that I would expect. Can someone shed some
light on this?

Thanks,

Craig


 Reply:
by:Armin Zingler

 
Replace is a function. It returns a *new* string because the string content
can *not* be changed.

mytest = MyTest.Replace("<", "<")
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



 Reply:
by:Peter van der Goes

 
If you need to modify existing contents, you need to use the
System.Text.StringBuilder class instead of the String class. StringBuilder
objects are mutable. String objects are immutable.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.


 Reply:
by:Cor Ligthert

 Hi Peter,

> If you need to modify existing contents, you need to use the
> System.Text.StringBuilder class instead of the String class. StringBuilder
> objects are mutable. String objects are immutable.

To my suprise as well has that no effect on the replace, the string replace
is slighly faster, we did a test in this newsgroup, here the final link to
that thread.

http://tinyurl.com/3bogd

Cor


 Reply:
by:Peter van der Goes

 
I was referring to the general issue of mutability. Not in particular to the
Replace method, or to any performance concerns. The parameter lists for the
Replace methods for the two classes explains the behavior.



Posted by Xander Zelders
0 Comments



SNMP

Found the following interesting discussion in the Newsgroups:

SNMP
by:SLE

Hi there,

I have found some (free) SNMP wrappers in C# (implementation via sockets),
but is it possible to use the standard System.Management classes to "get"
SNMP info from any device (e.g. printer)?
Thanks,

--
SLE


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

 
If you don't get an answer here, you may want to turn to this group:
<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.wmi>.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Errortext in datagridrow

Found the following interesting discussion in the Newsgroups:

Errortext in datagridrow
by:Lekker Ding

Hi

In which object/class can i find the errortext that displays once i
hover over the (red) erroricon in the current row of a datagrid?

Thanks!

LD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


 Reply:
by:Cor Ligthert

 Hi LD,

Probably errorprovider

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

Cor

"Lekker Ding" <peesa_govno@hotmail.com> schreef in bericht
news:uBtDjzvQEHA.2132@TK2MSFTNGP11.phx.gbl...



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

 * Lekker Ding <peesa_govno@hotmail.com> scripsit:
> In which object/class can i find the errortext that displays once i
> hover over the (red) erroricon in the current row of a datagrid?

You can set this text using your 'DataRow''s 'SetColumnError' method.

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


 Reply:
by:Lekker Ding

 Hi

sorry i forgot to tell that the datagrid is bound to a sql server table.
The sqlserver message that is not set by me , in which class can i find
it ? i tried something like
MyDataSet.Tables(0).Rows(0).GetColumnError(0)?

thanks

LD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Posted by Xander Zelders
0 Comments



How to add a item into a textbox?

Found the following interesting discussion in the Newsgroups:

add a item into a textbox?
by:jack.xu

a item has a text property and a value property.Can i add a such item into a
textbox?And the textbox only show item's text.

thanks in advance


 Reply:
by:Cor Ligthert

 Hi Jack,

I do not if it is a windowform or a webform, however with the windowform you
can maybe use the tag property.

Cor


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

 
\\Me.TextBox1.AppendText(foo.Text)
///

--
Herfried K. Wagner [MVP]


 Reply:
by:jack.xu

 thank you both!but I don't know if i add two or more items it would work?



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

 
What would you expect? The text for each item will be appended...

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Adding a button (data)column to a datagrid?

Found the following interesting discussion in the Newsgroups:

adding a button (data)column to a datagrid?
by:Steven

Is it possible to add a button datacolumn to a datagrid?

If so, how? Can you please give me an example?

Thanks! Steven


 Reply:
by:Cor Ligthert

 Hi Steven,

A link, that one I did not test by the way.

Button
http://www.i-syn.gmxhome.de/devcom/colstyles/controlbutton.htm

I hope it helps?

Cor


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

 
<URL:http://dotnet.leadit.be/extendeddatagrid/> allows you to place any
control in the column.

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


 Reply:
by:Ken Tucker [MVP]

 Hi,

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

Ken



Posted by Xander Zelders
0 Comments



Handling windows scroll

Found the following interesting discussion in the Newsgroups:

Handling windows scroll
by:amirali000@hotmail-dot-com.no-spam.invalid (Amir Ali)

Deal All,

Will somebody guide me how I can handle Windows scroll.

Means, it should be in my hand when I allow scrolling or not. Also,
Scroll should be visible and enabled always.

Is it possible.

Amir Ali.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


 Reply:
by:Cor Ligthert

 Hi Amir,

Did you already look to the autoscroll property of a form, it is default
false.

Cor


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

 
Please be more specific and give samples of what you want to do.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Inter-thread communication to pass a job to another thread

Found the following interesting discussion in the Newsgroups:

Inter-thread communication to pass a job to another thread
by:jlavery@bigfoot.com (James Lavery)

Hi everyone,
We're developing an application to capture data from several serial
ports, store in a database, and (optionally) forward on using FTP.

Each serial port is being processed in a thread, so that capture of
data can continue if the UI is blocked with a modal dialg, for
example.

I would like each thread to be able to pass any FTP work to a
dedicated thread, so that its data capture is not interrupted if the
FTP takes a long time.

So what I'm looking at is:

main thread
--- capture thread A
--- capture thread B
--- ftp thread

The big question is: how do I pass the ftp data from threads A/B to
the FTP thread?

In a similar vein, am I going to have problems if thread A and thread
B are both writing to my MSDE database?

The other question, of course, is whether there's a better way to do
it!

Any pointers greatly appreciated!

Thanks,

James


 Reply:
by:Cor Ligthert

 Hi James,

This seams a bit as Charles Law is busy with, however I get the idea you
have fixed the part of the serial port to the database as I understand your
question well. Maybe you can have a look at his problem in this newsgroup
and give him some advices.

In my opinion is the FTP is a File Transfer Protocol, so you can only send
file by file (that can be done in more threads) however in my idea that can
only be done when the file is complete.

In a message I gave Charles the idea to use a queue. The same idea I get
when I hear your problem. To Charles I said that a simple arraylist is very
suitable for his problem in my opinion. However for you problem I think that
can be even more. Putting in that queue the files which have to be
transfered can be a very simple sollution in combination with
multithreading.

When I do miss something, tell me what I miss?

Cor


 Reply:
by:Charles Law

 Hi James

How about creating two classes: one which contains a (thread) method that
performs the data capture, and one that contains a method that performs ftp
work.

Create objects of these two classes and start the threads going from you UI
thread. Then you can carry on doing UI stuff.

When the data capture thread gets ftp work to be done, have it raise an
event that is handled in your UI thread. All the handler does is place the
work in a queue managed by the ftp thread, and pulses the queue object to
inform the ftp thread that something is ready. The UI thread then returns to
what it was doing.

If you don't want the UI thread to be bothered by any of this, you could
have a thread that just waits for events from data capture threads and
passes them to the ftp thread.

HTH

Charles



Posted by Xander Zelders
0 Comments



How to read NULL values in SQL using VB .net

Found the following interesting discussion in the Newsgroups:

How to read NULL values in SQL using VB .net
by:Anonymous

Dear folks,
I have a column of data in MS SQL that is being read by my VB .net program. There are a couple of blank/NULL data in those columns. How do I read that data as NULL in VB .net and then make the program skip it. Any pointers would be appreciated.

cheers,

Ranjan



 Reply:
by:Ken Tucker [MVP]

 Hi,

Here is a quick example.

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")

For intRow As Integer = 0 To ds.Tables("Customers").Rows.Count - 1
Dim dr As DataRow = ds.Tables("Customers").Rows(intRow)
For x As Integer = 0 To ds.Tables("Customers").Columns.Count - 1
If Not dr.IsNull(x) Then
Debug.WriteLine(dr.Item(x))
Else
Debug.WriteLine("Null")
End If
Next
Next

Ken



Posted by Xander Zelders
0 Comments



NullReferenceException occuring on installed exe

Found the following interesting discussion in the Newsgroups:

NullReferenceException occuring on installed exe
by:BoloBaby

OK,

I have a brand new computer for my client. It is a *clean* Windows XP
system.

I ran dotnotfx.exe on the system to install the .Net framework. I checked
under add/remove programs and it appears to be installed correctly.

I installed my app on the system. I clicked the executable after the
install and I get a list of NullReferenceExceptions that are refering to the
controls on the form. If I click continue, the form comes up, painted
correctly. But if I interact with any of the controls (all standard window
controls), I get a new NullReferenceException.

This says to me that .Net framework is not properly installed. I
uninstalled and reinstalled. Same problem.

What am I missing? Any thoughts?

Gardner


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

 
Can you post the complete exception message?

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Marshalling question

Found the following interesting discussion in the Newsgroups:

Marshalling question
by:MyAlias

Private Structure WCRANGE
Dim wcLow As Short
Dim cGlyphs As Short
End Structure

Private Structure GLYPHSET
Dim cbThis As Integer
Dim flAccel As Integer
Dim cGlyphsSupported As Integer
Dim cRanges As Integer
-> <MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst:=100)> Dim
ranges() As Integer
End Structure

what marshall parameters to use to declare
ranges() As WCRANGE
instead of
ranges() As Integer
in order to have EXACTLY the same memory contents?

Thanks for taking your time



 Reply:
by:Tom Shelton

 
The current marshaller does not support arrays of structs inside of
structs... So basically you can't substitue WCRANGE for Integer. You'll
have to use the Integer array and then break the integer down into two
shorts manually.

I need to see if the 2005 marshaller supports this...

--
Tom Shelton [MVP]


 Reply:
by:MyAlias

 Thanks for all your answers
and sorry to repeat the subject,
i started this thread before reading your answer to another thread
:)

I also hope that the 2005 NET supports much more stuff than the 2003



Posted by Xander Zelders
0 Comments



Help! How do I get MS Access Field Properties in VB.net?

Found the following interesting discussion in the Newsgroups:

Help! How do I get MS Access Field Properties in VB.net?
by:Anonymous

Hi there,
I am a bit new to vb.net. I have figured out how to use a data reader to get column and row information from my MS Access database using OLEDB. The problem is that while I can easily get the column names, I can NOT seem to get any properties associated with a given col.

For example, I have configured specific CAPTIONS in my Access DB that I would like utilize in my vb.net program. Any help would be appreciated!



 Reply:
by:Anonymous

 Please don't take my word for it, but i am sure any additional functionality provided by a specific back-end can only be accessible programatically ONLY IF the specific ODBC driver supports such functionality.

Did you try this in VB6, for example. Not by referencing the Access class by via ODBC.


 Reply:
by:Cor Ligthert

 Hi Dtemlak,

I have seen this as well, however maybe you can ask this question as well in
the newsgroup

Maybe we get than both the answer.

Cor

Adonet
<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

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

\\ I am a bit new to vb.net. I have figured out how to use a data reader to
get column and row information from my MS Access database using OLEDB. The
problem is that while I can easily get the column names, I can NOT seem to
get any properties associated with a given col.
>
> For example, I have configured specific CAPTIONS in my Access DB that I
would like utilize in my vb.net program. Any help would be appreciated!
>



Posted by Xander Zelders
0 Comments



Deployment

Found the following interesting discussion in the Newsgroups:

Deployment
by:Deployment

Is this possible?

I need a file stored on every machine using my program in
VB.NET. It's a utility that will be ran from a shell
command.

When a user opens my applicaiton it will look for this
file. If not found I need an install package to be ran
to install the file. Can an install package be imbedded
into a .NET app and be ran automatically like this
situition requires.

If the file is found then it will skip running the
install package.

Anyone know any good articles on deployment! I will
manually install the framework on machines unless there
is a way to do this through the deployment process with
the .NET installer but from my findings Microsoft
prohibits it with there installer.

Thanks


 Reply:
by:Anonymous

 If the file you need is small enough you can store it as and embedded resource and then write it out if it is not avbl.

Rgds,
Anand
VB.NET MVP

http://www.dotnetindia.com



Posted by Xander Zelders
0 Comments



How to a .gz file in an VB.net?

Found the following interesting discussion in the Newsgroups:

How to a .gz file in an VB.net?
by:KC

I've trying to read a webpage. I built a procedure to do this nicely for an
ordinary page, my problem is reading compressed files. I have a page that (I
believe) is a zip file http://...omdata.gz. When I read this through IE it
reads it fine (although sometimes it tries to download the file...not every
time, which is odd), but when I try reading the page through my application
I get garbage characters. I'm guessing IE decompresses the file before
display.

How do I do that in VB.net. Treat the file like it's text that I can display
(or read) like a regular page?

--------
Ken Hunt
678-644-6036


 Reply:
by:lancer@nsoftware.removeme.com

 > I've trying to read a webpage. I built a procedure to do this nicely
> for
an ordinary page, my problem is reading compressed files. I have a
> page that
(I
> believe) is a zip file http://...omdata.gz. When I read this through IE it
reads it fine (although sometimes it tries to download the file...not every
time, which is odd), but when I try reading the page through my application I
get garbage characters. I'm guessing IE decompresses the file before display.
>

> How do I do that in VB.net. Treat the file like it's text that I can display
(or read) like a regular page?

IP*Works! Zip contains a Gzip component that
can uncompress and compress gzips. Also, IP*Works! the base package has an HTTP
component that supports gzip compression in HTTP retreivals (like
IE).

Regards,
Lance R.
/n software
http://www.nsoftware.com/

-




Posted by Xander Zelders
0 Comments



VB program and EXE

Found the following interesting discussion in the Newsgroups:

VB program and EXE
by:brian

I am very new at this type of situition and am looking
for guidance:

I am using VB.NET 2002 to write an app.
I have an .exe that needs to be incorporated into my
program. It's an RSYNC(novell synching utility)exe

I am going to get a job number and year from the user.
This will allow me to build a string of where the file is
stored in the directory.

Once I build the string I am going to run a shell command
from within my program such as:
c:\cwrsync\rsync.exe -vaz /cygdrive/c/TrussJobs/....etc

c:\cwrsync\rsync.exe (<--The exe I need to run)

Is there a way to store this file in a VB.NET program
when compiling and then copy it to the user without them
knowing it when the form is loaded so it is in place upon
submission?

OR

Is there a way to store an .exe in the program and when
trying to process the shell I can locate it somewhere?

So- in recaps, I need help distribuitng an exe to the
user in order to get my shell command to work properly.

This is not being used for corruption but to save my
users from needing to terminal in to our central location
and copy data. RSYNC can handle the copying of data for
us freeing up a lot of time and reducing bandwith greatly
since it compresses on the fly.

Thanks for any suggestions!


 Reply:
by:Sven Groot

 
If you can't just bundle the exe as a separate file with your own app, you
could embed the exe in your program as a resource.
You can then access it as a stream, write that stream out to a file and then
Shell out to that file when you need to use it. You can get at the embedded
resource stream using this:
Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApp.rsync.exe")

To get the file as a resource in your app, just add it to the project in
VS.NET and set its build action to "Embedded Resource".

--
Sven Groot

http://unforgiven.bloghorn.com



 Reply:
by:brian shannon

 
Thanks for the reply.

By chance would you be able to give an example on how to write the
stream to a file?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Posted by Xander Zelders
0 Comments



Getting program to wait

Found the following interesting discussion in the Newsgroups:

Getting program to wait
by:Anonymous

I'm using VB.Net to process information out of a word document. If the document fails a test, I would like to close it and move it to an error folder. However, when I try to do that (see below) it says that another process is using the document. Is there some way to force the move to wait for the doc to close?
Thanks.

Dim wrd As Word.Application = New Word.Application
Dim doc As Word.Document

For Each sFile In Files
strName = CPAPDataPath & sFile.ToString
doc = wrd.Documents.Open(strName)

*** Processing Here ***
If...
*** Processing Here ***
Else
wrd.Quit()
sFile.MoveTo(CPAPErrorPath & sFile.Name.ToString)
End If


 Reply:
by:Ken Tucker [MVP]

 Hi,

Try this. You need to use marshal.releasecomobject to get word to
close.

wrd.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wrd)
GC.Collect()

sFile.MoveTo(CPAPErrorPath & sFile.Name.ToString)
Ken



Posted by Xander Zelders
0 Comments



Excel and vb.net

Found the following interesting discussion in the Newsgroups:

Excel and vb.net
by:MadIndian

I am using this code to change the page orientation in excel, previously
worked fine now it takes 20 seconds to execute any ideas are greatly
appreciated

Code:
Dim objExcel As New Excel.Application

Dim objBook As Excel.Workbook = objExcel.Workbooks.Add

Dim objSheet As Excel.Worksheet = CType(objBook.Worksheets(1),
Excel.Worksheet)

objSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape ' Hangs
here and never used to then continues on

Keith


 Reply:
by:mwazir

 I have used Excel in my application and I found that Excel used to take a
lot longer to finish if its visible property was True. I dont know if it is
applicable to your scenario but try it out

objExcel.Visible = False ' After creating the Excel instance
objExcel.Visible = True ' At the end of your excel operation.
In many cases you wouldnt even need to set it back to True because you want
Excel to do some operations behind the scene for you.

HTH

--
Wazir



Posted by Xander Zelders
0 Comments



How to get attributes provide by in System.Runtime.InteropServices

Found the following interesting discussion in the Newsgroups:

How to get attributes provide by in System.Runtime.InteropServices
by:Anonymous

I am trying to get the FieldOffsetAttribute attached to a structure I have defined. Here is some sample code. The GetCustomAttribute call returns Nothing. So I am assuming that FieldOffsetAttribute is not a custom attribute. OK. So what is it and how can I get it.

Imports System.Runtime.InteropServices
Imports System.Reflection

Module Module1

<StructLayout(LayoutKind.Sequential)> _
Public Structure MyStruct
<FieldOffset(0)> Public aShort As Short
<FieldOffset(2)> Public aByte As Byte
End Structure

Sub Main()
Dim type As System.Type = GetType(MyStruct)

For Each fi As FieldInfo In type.GetFields
Dim fo As FieldOffsetAttribute = Attribute.GetCustomAttribute(fi, GetType(FieldOffsetAttribute))
If (fo Is Nothing) Then
Debug.WriteLine("No Attribute")
Else
Debug.WriteLine("Found Attribute")
End If
Next
End Sub

End Module

Any help would be greatly appreciated.

Peace
John K.


 Reply:
by:Mattias Sjögren

 
For .NET v1.x, these attributes aren't returned by Reflection. The
only way to read them is with the unmanaged COM based metadata API os
some other metadata reading library.

In v2.0 the attributes should be returned (at least they were last
time I looked).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.



Posted by Xander Zelders
0 Comments



DataGrid Issues

Found the following interesting discussion in the Newsgroups:

DataGrid Issues
by:Anonymous

I am having two issues with my datagrid. First, my column headers are not displaying.

Second, the grid runs and displays correctly (except the headers) the first time. When the grid runs for the second time I get an error:

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Cannot create a child list for field Additional.
The code is below. Does anyone see the error?

Thanks in Advance,
Elena

strsql = "Select add_desc, add_cost from Additional where expense_id = " & TextBox3.Text & " order by add_id desc"
Debug.Write(strsql)

' Create data adapter object
Dim daGrid As OleDbDataAdapter = New OleDbDataAdapter(strsql, Expenses.conn)

' Create a dataset object and fill with data using data adapter's Fill method
Dim dsGrid As DataSet = New DataSet
daGrid.Fill(dsGrid, "Additional")
Dim dvGrid As DataView = dsGrid.Tables("Additional").DefaultView
DataGrid1.DataMember = "Additional"
DataGrid1.DataSource = dvGrid

Dim dgts As DataGridTableStyle = New DataGridTableStyle
dgts.MappingName = "Additional"

dgts.GridColumnStyles.Add(New DataGridTextBoxColumn)
dgts.GridColumnStyles.Item(0).MappingName = "add_desc"
dgts.GridColumnStyles.Item(0).HeaderText = "Description"
dgts.GridColumnStyles.Item(0).Width = 300
dgts.GridColumnStyles.Add(New DataGridTextBoxColumn)
dgts.GridColumnStyles.Item(1).MappingName = "add_cost"
dgts.GridColumnStyles.Item(1).HeaderText = "Cost"
dgts.GridColumnStyles.Item(1).Width = 200


 Reply:
by:Ken Tucker [MVP]

 Hi,

I dont see where you add the datagrid table style to the datagrid.

Ken


 Reply:
by:Anonymous

 One problem solved! I can't believe I forgot to add the style.

Anyway, the second error is still coming up.

Any Ideas?

Thanks,
Elena


----- Ken Tucker [MVP] wrote: -----

Hi,

I dont see where you add the datagrid table style to the datagrid.

Ken



 Reply:
by:Ken Tucker [MVP]

 Hi,

Try deleting this line. You shouldn't need to set the datamember if
you are binding to a dataview.

DataGrid1.DataMember = "Additional"

Ken


 Reply:
by:Anonymous

 YAY! Thank you, Thank you, Thank you!!!

Finally!
Elena


----- Ken Tucker [MVP] wrote: -----

Hi,

Try deleting this line. You shouldn't need to set the datamember if
you are binding to a dataview.

DataGrid1.DataMember = "Additional"

Ken



Posted by Xander Zelders
0 Comments



format listbox

Found the following interesting discussion in the Newsgroups:

format listbox
by:B.Etienne

I wish to display the contents of a 2 dimentional array
I think i should use a list box. I wish the output of my array in the
form of 4 rows and 4 colms like a matrix. Can you post some code for
this?

0 0 0 0 1
0 0 1 0 0
0 0 0 0 0
1 0 0 1 0


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

 

Use a ListView with 'View' set to 'Details' and subitems containing the
values.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Memory Usage and Page File Usage - Help!

Found the following interesting discussion in the Newsgroups:

Memory Usage and Page File Usage - Help!
by:RH

Hi,

I am building a windows application that has a feature that retrieves a set
of records when a button is clicked. When the records are being retrieved I
experience a complete system degradation, including other programs that
become unresponsive.

Here's what I found while the retrieval process is running:

Using the Windows Task Manager, I can see the the "Page File (PF) Usage"
indicator under the Performance tab increase in value from 360 MB to over
often over 1 GB when returning 3000-6000 records.

The "Mem Usage" indicator under the Processes tab increases from 40,000K to
over 300,000K.

When the operation is done, the memory usage levels remain the same and the
response time for my whole computer remains slow. Only until after the
application is closed does the memory usage levels go back down and my
computer returns to its normal response time.

Also, I'm not sure if this matters but the table that contains these records
has a column of type "text" which may contain data in the size of 100-5000
characters.

Any help on what is going on and suggestions on how to fix this would be
appreciated. Thanks!




 Reply:
by:John J. Hughes II

 You did not say how you were obtaining the data.

My application can put 5000 records of about 300 bytes each from the SQL
server on another machine in a few seconds. Text will take longer per
records because of the way it's fetched but I have a few windows that
display 'ntext' from the SQL and at about 1000 records and 2k size I have
not noticed anything like you are talking about.

I don't pay a lot of attention to memory allication but any application
written in .NET seems to use more then I am use to. They say the memory is
returned but I have noticed this is not very often. My application seems to
be pretty good about not allocating more memory if I just reload the new
data and dispose of the old so when you hit your peak it should not go above
that point. The application I am working on is MDI and basically unless I
load an awful lot of records 10K+ with several windows I don't have a memory
problem on a system with 1Gig.

You can try calling gagbage disposal if it continues to be a problem.

Sample code might also help someone that knows more about this then I.

Hope this helps,
John


 Reply:
by:Nicholas Paldino [.NET/C# MVP]

 RH,

I assume you are using a DataSet to store all of this data. Is it
really required to have all of that information in memory, or are you
processing all of that data and then just letting it go? I can't imagine
you binding a UI element to 3000 records.

What are you trying to do that you need all 3000 records in memory at
once?
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com



 Reply:
by:RH

 These records are being stored in a collection and they are not being bound
to a UI element. These records contain a column of type "text" that contains
XML data which will be parsed later on in the process.

Just now I have modified my code to work with smaller chunks of 500 records
at a time instead of the whole lot of 3000+ records. But it made no
difference in that after being done with a chunk of 500 records, the memory
usage did not reset or clear. Instead, it grew every time a new chuck of
records were being processed.

Any suggestions? Is there a way to explicity release the data in memory once
the code is done with it?

Thanks in advance.


 Reply:
by:John J. Hughes II

 See the System.GC class to clear memory.

Regards,
John



Posted by Xander Zelders
0 Comments



Image ComboBox-How to use them?

Found the following interesting discussion in the Newsgroups:

Image ComboBox-How to use them?
by:D T

hi,
there is an component you can load
that comes with Microsoft VB 6.0 called Microsoft Windows Common
Controls 6.0 (sp6) (MsComClt.ocx). There U can find a control called
ImageCombo. I would like to know how to use them.
Thanx

|DT|

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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

 
Documentation:

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

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Scroll Bar

Found the following interesting discussion in the Newsgroups:

Scroll Bar
by:Anonymous

I use the following code to add a vScrollbar to a form. How do I get it so if the form height is changed, the scroll bar maximum is changed to reflex then new size. The lastControl is the last Control on the form, which would be the height of the form. I call this on resize of the form. It works fine it the form is not resized. If the form is shortened, the scroll bar does not scroll down to the last control. It the form is lengthened, the scroll bar scrolls to far.

Private Sub SetupVscroll()
Dim iFullFormHeight As Long
Dim iDisplayHeight As Long

iFullFormHeight = lastControl.Top + lastControl.Height ' - 50
theScrollBar = New VScrollBar()
With theScrollBar
.Parent = Me
.SetBounds(Panel1.Left + Panel1.Width + 1, Panel1.Top, 16, 248)
.Height = Panel1.Height
.Minimum = 0
.Maximum = iFullFormHeight
.SmallChange = 100
.LargeChange = .SmallChange * 20
.Show()
End With
End Sub

Thanks in advance!


 Reply:
by:Anonymous

 I got it. Thanks anyway!



Posted by Xander Zelders
0 Comments