|
Allen,
thank you.
It works.
When my form is loaded, grid does not have focus. In this case grid first cell is highlighted.
I tried to set Selected false in Grid constructor
public Grid() {<br />
InitializeComponent();<br />
CurrentCell.Selected = false;<br />
}
But got NullReferenceException since CurrentCell is null
How to disable cell selection when grid is initiated ?
Andrus
|
|
|
|
|
Hi
if i select on path like c:\\Test\Test1\Test2\test3\test.txt [See Photo]
now once i chose this path from computer ...and want to separate in program like
fline name: test
ext: .txt
Drive: c
folder1: Test
folder2: Test1
folder3: Test2
folder4: Test3
folder5:
if there is more then 5 folder then message will print out like " You have more then 5 folder "
I need help for this program... is that any one can help me how to make program like this in
Language C#
Peter
|
|
|
|
|
The split method of the string class will do this for you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
If i have vriable
string i; // i = 34245 (Whatever use put a number)
If i want to separate the "34245"(by one digit)So what method should i use.
i want to make a program where usere put any number and result come like
12345
one two three four five.
Is thay anyone can help me with that ?
-Thanks
Peter
|
|
|
|
|
A string is an array of chars. foreach(char c in "12345") will iterate over the numbers. If you have non numbers in your string, Char.IsDigit will tell you if it's a number.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
in ouput only comes the value of last digit
if out put is
12345
five
it's loop through one two three four five but pirnt only five ?
no one two three four is on screen only five... can you tell me how should i get the whole value ?
12345
one two three four five
-Thanks
Peter
|
|
|
|
|
I have no idea where your code is broken, you've not posted it.
foreach(char c in "12345")
{
switch(c)
{
case '1':
// print 'one'
// etc
}
}
will most certainly work.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ah, but a Dictionary<char,string> would be so much more flexible and the teacher will be most impressed.
|
|
|
|
|
Yeah, until the teacher asked him to explain the code....
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Oh, in that case maybe an enum .
|
|
|
|
|
How about just an array of strings and int.TryParse to get the index ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I try this method and it's work
string[] spliter = fileName.Split(new char[]{'\\'});
-thanks for ur support
Peter
|
|
|
|
|
I seriously doubt it's homework help he's asking.
Cheers,
Vikram.
Zeppelin's law: In any Soapbox discussion involving Stan Shannon, the probability of the term "leftist" or "Marxist" appearing approaches 1 monotonically.
Harris' addendum: I think you meant "monotonously".
Martin's second addendum: Jeffersonian... I think that should at least get a mention.
|
|
|
|
|
Oh, no, most assuredly not.
|
|
|
|
|
Hey all i am trying to make an application which can read text from an image. I am able to read image with OCR but the problem is that i have to read only information written on a label which is dispatched manually on the document before scanning. First i have to search that label through out the image and then check if it is straight or not if it is not then i have to make it straight to make it readable for my OCR.
I am seriously in a big trouble with this thing so if anyone can help me i will appreciate your concern .
|
|
|
|
|
Sounds like a major task to me. You can use edge detection or segmentation to try to work out where your label is, perhaps. You can then use this to work out if the label is straight, and perform a rotation.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello
I have a lengthly process which takes sometime couple of minutes. I like to update the statusbar to give some feedback to the user. When I tried to update the label of a statusstip from inside a lengthly loop, statusstrip does not show the updated result until it finishes the all iteration.
Here is my experiemental function.
for (int i = 1; i <= 50000; i++)<br />
{<br />
System.String str = "Iteration # ";
str += i.ToString();<br />
<br />
if ( (i % 1000) == 0)<br />
{<br />
toolStripStatusLabel1.Text = str;
}<br />
<br />
}<br />
When I run this function, it just display the final result which show "Iteration # 50000". It does not show any intermediate iteration.
Is it blocking the thread? Even though I put time consuming operation inside the function, still it does not show the intermediate statusstrip update.
Does any body know, how I can update the lable of a statusstrip to update the iteration number within a loop.
Thank you in advance.
|
|
|
|
|
According to your experimental function provided, it should work. Is the real function similar in logic and sequence to this one? Also, I would clear the text then re-set it (This is not a solution to your problem, but recommendation.)
Normally operation which take so long can be put into a separate thread and provide feedback to user at same time in a different thread.
|
|
|
|
|
Yes, real function is same as this one. statusbar only update once it finishes the loop, does not updata any intermediate iteration. My guess is that, UI thread might be freeze until loop finishes. Otherwise I am not sure why it does not update in between.
Still looking for some more help.
Thank you.
|
|
|
|
|
I am not sure where you are initiating the function from. Is it in an event handler? In any case try the following and it should work.
The idea is to create a thread and ask the thread to do some work for you--in your case do the loop. Then ever 100 iteration ask the form to update itself using a delegate.
You should improve this code as per your need but here it is anyways.
public delegate void UpdateLabel();
private Thread loopThread = null;
private string str;
private void button1_Click(object sender, EventArgs e)
{
loopThread = new Thread(new ThreadStart(DoTheLoop));
loopThread.Start();
//aThread.Join();
}
private void DoTheLoop()
{
for (int i = 1; i <= 500000; i++)
{
str = "Iteration # "; // deliberately created inside the loop
str += i.ToString();
if ((i % 100) == 0)
{
//toolStripStatusLabel1.Text = string.Empty;
//toolStripStatusLabel1.Text = str; // Update statusstrip lebel every 1000 iteration.
// Ask the form to Invoke the delegate and ask it to update the label
this.Invoke(new UpdateLabel(UpdateStatusStrip));
}
// ask the loopThread to sleep for a while so processor can do something else
Thread.Sleep(10);
}
}
private void UpdateStatusStrip()
{
toolStripStatusLabel1.Text = string.Empty;
toolStripStatusLabel1.Text = str; // Update statusstrip lebel every 1000 iteration.
}
Let me know if you have any questions.
|
|
|
|
|
Hi
Thanks for your advice. I tried your idea. It works but it does not show all the updates instead it skips many updates. when I wrote === if ((i % 10 ) == 0) == this condition, it does not show all 10, 20 ,30 ..... etc. Sometimes it jumps from 12450 to 16240 (as an example). It looks like before updating one call, loops continue and many calls are discarded because previous one still not finish and when one updating finish, it does not attemp to update next one instead updating the current one.
I tried another idea from another poster from this thread and he suggested to use Application.DoEvents() and it works fine and shows all the updates sequentially.
Thank you for your advice.
|
|
|
|
|
Hi,
if all this code is running on the GUI thread (say inside a button click handler),
then it is normal the GUI is dead until your code finishes, at which point it would
show the final status text only. You could fix that by adding a line
Application.DoEvents() after changing label.Text (this is a dangerous
hack, if your code gets re-entered a stack overflow may occur, so disable the
button that started this for as long as it takes).
if all this code is supposed to run on a separate thread (in an attempt to keep
the GUI alive), then you need to use Control.InvokeRequired and Control.Invoke
to update any GUI component.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank you for your suggession. I tried your idea and it works in my test case.
|
|
|
|
|
Hi,
I have a class which should return an xml file to a client. The client in this case will use IE to display the contents.
What type should I return to the client so it is the friendliest? In other words I do not want the client to have to write too much code just to see the contents.
Thanks
|
|
|
|
|
The best thing to do is to return the XML as a string . The client can then do whatever it wants with it. In your case, the XML can be written out in a HTTP Response. IE will display it using its own XML Viewer.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|