|
Thank you for your response. I appreciate it.
sasa
|
|
|
|
|
SASA_1 wrote: I am a newbie in C# and I need some help. If I open a database connection in my try statement, can I close it in finally. i.e. is finally always executed?
Yes - the code in finally is always executed.
I'm new myself so won't comment on the code - if it works then it's fine Worry about perfection in a few months time!
Glen Harvy
|
|
|
|
|
Hi,
i need to translate a c# webcontrol in asp code.
For example:
Button b = new Button();
to
<asp:button id="Button1" runat="server" Text="Button"></asp:button>
I would pre-generate aspx page that can be modified in Visual Studio 2005.
Thank You
BDN
|
|
|
|
|
The combo box is usually used to select a value from a predefined list to insert into another object. So, in general we bind the ComboBox to the list of values and get the SelectedValue for updating.
My question is this: is there a simple way for the ComboBox to updates its own values when a user types values?
My ComboBox is bound to a three column data table and in my wildest dreams I'd like for the user to type a value and the datatable updates the value previiously selected instead of moving the SelectedIndex to -1.
I didn't find any example of this anywhere.
Thanks in advance.
|
|
|
|
|
Are you working in WinForms or ASP.NET? It makes a world of difference.
|
|
|
|
|
Sorry, important detail, I work in WinForms
|
|
|
|
|
The program I’m working on allows the user to produce a number of pictureboxes, set their pictures and drag them around. I also needed to store extra information about each picturebox, so I created a class called ‘item’ that has values such as ‘previousx’ ‘previousy’ etc. At the moment I have an ‘item’ for each picturebox, and all the ‘items’ in a collection so that when the user starts working with a different picturebox, the program has to look through the collection to find the correct item, so it can display the correct variables.
However, I realised that the Tag property of each picturebox can take an object, not just a single string or int etc. So attaching each picturebox’s item class to its tag should be more efficient and easier to work with. My problem is, how do I go about accessing the variables once they are stored in the tag. For example,
x = pictureBox1.Tag.previousx
would give an error on compile, as the property does not exist at build time. Is there any way to get this to work?
Thanks for the help.
|
|
|
|
|
Here is an example : the ... represents a jump in your code to the appropriate location.
ValueItem item = new ValueItem();
...
pictureBox1.Tag = item;
...
ValueItem item = (ValueItem) pictureBoxn.Tag;
this.descriptor.Text = item.Description;
|
|
|
|
|
Hello,
I am using Membership's encrypt/decrypt methods. When I encrypt the string, it increases the length of the string. Is there any way I can set the lenght of encrypted string?
OR is there any way to know how much length will increase after encryption. based on that I need to set length of column in database.
Thanks in advance.
- ashish
|
|
|
|
|
hi
i want to print my form .. how to do ??
and how to print multiple page (for example a datagrid with many record or a form with many controls) ??
thanks ..
bye ..
|
|
|
|
|
|
yes .. i know . but how to use these classes and objects ??
|
|
|
|
|
Can you tell me how to give power to transistor or somethiog else?
|
|
|
|
|
What exactly does this have to do with C#
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Use Google -> Look for Electronic Forum.
|
|
|
|
|
You can use the SSystem.IO.Ports.SerialPort class in .net 2.0 or use one of the plethora of Interop libraries out there...
/\ |_ E X E GG
|
|
|
|
|
I'm setting all my variables to null in my dispose method but it doesnt seem to work!!! The memory usage of the program does not go smaller, rather, the huge amount of memory is maintained! Why is it so?
Thanks very much!
|
|
|
|
|
Dispose is generally for unmanaged resources.
If you set all variables to null the garbage collector will eventually pick them up during one of the cleanup rounds. This may take a while though, this is why you dont notice anything when you set them to null.
WM.
What about weapons of mass-construction?
|
|
|
|
|
WillemM wrote: If you set all variables to null the garbage collector will eventually pick them up during one of the cleanup rounds.
This is an old myth carried over from Java. In C#, you don't need to set your variable to null in order for the GC to collect them. They will be collected when there's no more references to them, regardless of their null status.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I bet you're looking at Task Manager for this.
You're assuming that the numbers you see in Task Manager is how much memory your app is using. You're not.
The simplified version of what's happening...
What you are seeing is how much memory the Common Language Runtime that your app is running in (a virtual machine, just like any Java app) is using. This includes memory reserved for future allocations but not yet used by, or just freed by, your app. This is known as the Managed Heap. Memory requested by your application is allocated in the Managed Heap, and when freed by your app, is returned to the Managed Heap, not Windows.
The CLR maintains the Managed Heap and, using a self-tuning process, adjusts its size based on what your application has done in the past. If the CLR suspects your app will make large allocations in the near future, it'll maintain a larger Managed Heap, requesting more memory from Windows to do so. If it feels that it doesn't need as much memory in reserve, it'll release some of the Managed Heap memory back to Windows. Or, if Windows wants it back, it'll free up what it can and let Windows have whatever memory the CLR can free up from the Managed Heap.
SO, what you're seeing in Task Manager is not how much memory your application is using, but is how much memory the CLR Virtual Machine is using and has reserved for your app.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You don't need to use dispose; dispose isn't for cleaning up memory. It's for cleaning up unmanaged resources like socket connections, database connections, file streams, etc.
Each object in your program will be garbage collected when there are no more references to the object. And even then, it won't be collected until the garbage collector lazily comes along and cleans up (or if you force a collection via GC.Collect() )
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
The other major thing dispose cleans up are handles. With each control on a form having one, old forms are a prime candidate for disposal.
|
|
|
|
|
please send sample code for .net remoting concept in c#.net
|
|
|
|
|
Please read the How to get answers thread at the top of this forum
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
There are plenty of sample, here and elsewhere, try doing a search and reading them first, then if you have a specific question ask and we will try to help you.
only two letters away from being an asset
|
|
|
|
|
Feel like a broken record yet, Mark? Kids these days...
|
|
|
|