|
There isn't a whole lot different between opening an existing file and saving new data to it and opening a new file and saving new data to it. If you already have code to do one then the other is pretty much a cut and paste job . . .
is there something specific you're having a problem with?
|
|
|
|
|
Hi all,
I am trying to make the first letter to display as Capital,
i.e when user enters a text in the TextBox the first letter should be capital and the rest should be as they are.
e.g
this is a good example.
should be,
This is a good example.
Thanks,
Prashanth
|
|
|
|
|
The simplistic way:
Capture the keypress event, then read in the text that's already in the textbox. If this is the first alphabetic character, then convert it to uppercase using the string functions. Put the text into the textbox, then set the handled to true.
This is an extremely simplistic way that doesn't take into account things like the user entering text and then moving back to the start of the textbox and entering more text. A more comprehensive way requires you to change the contents of the textbox when it loses focus. That way, you can always find what the first character was - however, this is a single shot solution.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks alot for ur suggestion..
but I want to make the very first letter that the user is going to enter should be Capital..
Not the one thatz already in textbox , I want to make the one which user is going to enter.
thanks
|
|
|
|
|
So you need a psychic handler?
The handler will instinctively know which letter you are ABOUT to press and set CAPS LOCK ON and then turn it off once the letter has been pressed.
Cool.
I still remember having to write your own code in FORTRAN rather than be a cut and paste merchant being pampered by colour coded Intellisense - ahh proper programming - those were the days
|
|
|
|
|
Surely it can know which letter you just pressed, at what position, and change that letter to a capital?
|
|
|
|
|
Thanks, but
I don't know whatz psychic handler,
and How should I configure this handler to make the very first letter to make to CAPITAL.
as I am new here,please be clear.
thanks
|
|
|
|
|
Just like Microsoft Word Automatic Grammar/Spelling check?
|
|
|
|
|
psychic handler, not perfect. but it works
<br />
textbox1.KeyDown +=new KeyEventHandler(Psychic_Handler);<br />
<br />
private void Psychic_Handler(object sender, KeyEventArgs e)<br />
{<br />
if (((TextBox)sender).Text.Length == 0)<br />
{<br />
((TextBox)sender).Text = e.KeyCode.ToString().ToUpper();<br />
e.SuppressKeyPress = true;<br />
((TextBox)sender).SelectionStart = 1; <br />
}<br />
}<br /> If it' stuck, DO NOT pull harder!
|
|
|
|
|
Hi. This would be easy way to do first char in CAPS....
char ci = Convert.ToChar(TextBox1.Text.Substring(0, 1));
TextBox1.Text = TextBox1.Text.Remove(0, 1);
TextBox1.Text = ci.ToString().ToUpper() + TextBox1.Text;
Thanks
|
|
|
|
|
|
hi
all i was asked in interview how often the garbage collector
i.e. gc.collect() will get invoked
i know why? what? about garbage collectore but
interviewer asked me will it be for every 5 minutes the method invokes
can anyone help me...
bye
|
|
|
|
|
When 1) a memory allocation request exceeds the current generation 0 segment capacity (or because of an exlicit call to GC.Collect) and 2) the object is no longer reachable.
If we exclude GC.Collect calls, this means that a GC will only occur on allocation. In other words, objects may well be ready to be released but no allocations are made, meaning no GCs will occur, so memory usage will stay flat.
*jaans
|
|
|
|
|
|
kalyan_2416 wrote: how often the garbage collector
i.e. gc.collect() will get invoked
Gc.Collect() will invoke garbage collector immediately. But AFAIK, we can't predict the timings when GC invoked when Collect() is not used. I guess it will be invoked when a cleanup is required.
|
|
|
|
|
nice quote
yup the other friend also says what u have guessed
thanx bye
|
|
|
|
|
IIRC explicitly calling GC.Collect() is generally a bad idea. The deal is that it will encourage the garbage collector to promote objects that survive collection to a higher generation. The higher generations are collected less aggressively - which has obvious performance implications.
|
|
|
|
|
You recall correctly. There aren't many occassions, (I can't think or any offhand), where you should call it - let the runtime determine this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You may consider GC.Collect() when you want to get an optimal and/or repeatable
starting condition, examples:
- application has busy and idle periods, and wants to off-load as much work as possible
from the busy to the idle periods
- application is going to be observed/measured (as in the Setup method when using NUnit),
say for performance measurements.
And yes, these are exceptional situations.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Garbage collection in .NET is not based on frequency. Instead, it is a sophisticated algorithm that will collect the object at some point after the object has become eligible for collection.
Have a read of this[^] article.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
I am writing a UserControl that contains 20 similar 'other' controls. My basic control is also a usercontrol consisting of a Panel and a Button inside a parent Panel.
I need to create 20 of these simple usercontrols onto a bigger Usercontrol.
I have done this by using a array of this.
>> ucPanels[] iPanels = new ucPanels[20];
I call this method :
>> private void createMainPanel()
{
int z = 1;
for (int i = 0; i < 20; i++)
{
iPanels[i] = new ucPanels();
iPanels[i].Name = "myPanel" + i.ToString();
Controls.Add(iPanels[i]);
iPanels[i].Location = new System.Drawing.Point(z, 5);
iPanels[i].Click += new System.EventHandler(iPanels_Click_1);
iPanels[i].MouseDown += new System.Windows.Forms.MouseEventHandler(iPanels_MouseDown_1);
//iPanels[i].Size = new System.Drawing.Size(50,84);
z += 51;
}
}
private void iPanels_Click_1(object sender, EventArgs e)
{
for (int i = 0; i < 20; i++)
{
// I cannot reach this event
}
}
Is there anything wrong with my code as I cannot call my event iPanels_Click_1
Thanks
Amien
Amien
Cape Town
South Africa
|
|
|
|
|
If the panel is docked and filling the usercontrol you'd probably have to
add an event handler for the panels click on the usercontrol and then
call the usercontrols click event from there.
If it' stuck, DO NOT pull harder!
|
|
|
|
|
Hi,
How can i search in all columns of a table for a word that the user types in a textbox? some code pls?
|
|
|
|
|
DataTable have a Select() method which allows you to filter DataTable and returns DataRow array.
|
|
|
|
|
Aproximately:
...
DataTable dt = ...
string sText = txtInput.Text;
foreach(datacolumn in dt.columns)
{
if( typeof(datacolumn) == string )
{
DataRow[] oRows = dt.Select(DataColumn.Name + " = " + sText);
if( oRows.Count > 0 )
{
//Do wat you have to do
}
}
}
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|