|
Have a look at:
http://msdn2.microsoft.com/en-us/library/system.collections.ienumerator(VS.80).aspx
In particular:
An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to MoveNext or Reset throws an InvalidOperationException
And:
http://www.yoda.arachsys.com/csharp/threads/winforms.shtml
Regards
|
|
|
|
|
Hi,
cirkit1 wrote: I am not really changing anything in the listview.
whatever you want to do to a Control (set a property, get a property, call a method),
you must do so from the thread that created the Control in the first place.
With the exception of a few: Control.InvokeRequired, Control.Invoke(), etc.
So yes, you need the same "if InvokeRequired Invoke self" construct even to read a
ListView item.
BTW: Now you may choose to do this for each and every single Control access, or you may move
a higher-level method to the Control's thread of course, that would take more GUI time
(i.e. freeze your GUI longer), but all-in-all be better performance wise.
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
|
|
|
|
|
I'm a programming beginner so please be as harsh as you like but keep in mine I'm a complete "newb". I'm starting with C# and this is my first program.. a windows form app "cookbook" for my wife.
I'm outputting one element of an XML document to a windows form using LinQ in C# (2008 ve beta) and I'm having trouble with there being a random number of elements. For example here is the document.xml outline:
<br />
<cookbook><br />
<recipe><br />
<name /><br />
<description /><br />
<instructions /><br />
<ingredients><br />
<ingredient1><br />
<amount /><br />
<measurement /><br />
<item /><br />
</ingredient1><br />
[...]random number of ingredient nodes<br />
<ingredientX /><br />
</ingredients><br />
</recipe><br />
</cookbook><br />
So each "recipe" will have a different amount of ingredients and I won't know how many that is until I start querying the document. They will be named etc.
I've built the code to display everything but the ingredients, displayed below. I think I will have to next a foreach loop inside my current foreach loop to do this but the syntax I've tried has all been deadends. Does anybody have any experience with this in Linq?
<br />
XDocument cookbook = XDocument.Load(GlobalLogin.filename);
<br />
var display = from item in cookbook.Descendants("Recipe")
where item.Element("Name") != null && item.Element("Name").Value == name<br />
select new<br />
{<br />
Name = item.Element("Name").Value,<br />
Description = item.Element("Description").Value,<br />
Instructions = item.Element("Instructions").Value<br />
};
<br />
foreach (var item in display)
{<br />
Label recipename = new Label();
recipename.Text = item.Name + ": " + item.Description;<br />
recipename.Location = new Point(10, 10);<br />
Label instructions = new Label();
instructions.Text = item.Instructions;<br />
instructions.Location = new Point(10, 35);<br />
this.Controls.Add(recipename);
this.Controls.Add(instructions);<br />
}
I put nice little spaces in there to stagger it but it is ignoring them.. how do I get that to show up on this message board? Is there a way?
|
|
|
|
|
Do you create the XML structure? If so, don't add the number after ingredient. It's quite possible to have several elements with the same name. This will probably simplify things a bit for you. You just look for all elements with a certain name and loop through them.
|
|
|
|
|
Wow didn't know you could do that, heh. That makes things A LOT easier, thanks!
|
|
|
|
|
I have written a c# console application that updates active directory. To have the proper permissions to update active directory it runs under NT/Authority. I need to be able to find the user who logged on to update his AD fields. userName = Environment.UserName.ToString(); returns NT/Authority and I need the name of the user who is logged on, not the user running the service.
David Wilson
|
|
|
|
|
What if no one is logged in or multiple people are logged in?
|
|
|
|
|
If no one is logged in then the service will not do anything. The service will only be running on XP and Vista so multiple users will not be an issue.
|
|
|
|
|
Hi!
That's not true. You can swap users with XP and Vista, so chances are there actually are more than one user logged in.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
In my environment that can't happen. Users are required to use their smartcard to logon. If the card is removed the terminal locks. There is only one card reader so only one user can be logged in at one time.
|
|
|
|
|
dave@dmwilson.net wrote: In my environment that can't happen
I guess that's among the top ten statements that indicate that there'll be trouble later on.
Anyway, I think your best chance is to search for a Win32 function to retrieve the list of currently active sessions - I don't think there's something in the BCL to provide you with this information.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello to everybody,
first of all i want to express how useful these forums are and thank everyone for his help.
Now to my problem: i need to connect a wlan webcam to a pda with wm5. the webcam sends avi files which can be accessed by a normal webbrowser through activeX. Actually i need the stream to grab some images to send them further to an object tracker. The object tracker works fine on a win ce 5.0 system. So all i want to know is if it`s possible to do so and how can i solve that issue.
Thank you in advance.By the way it`s very urgent
|
|
|
|
|
the_chabo wrote: first of all i want to express how useful these forums are and thank everyone for his help
Awww, thanks
Let me think out your question you have
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
select HataKodu,HataAciklama,Count(HataKodu) as Toplam From Tablom Where HataKodID<>0 group by HataKodu,HataAciklama Order by HataAciklama Asc;
select HataKodu2,HataAciklama2,Count(HataKodu2) as Toplam From Tablom Where HataKodID2<>0 group by HataKodu2,HataAciklama2 Order by HataAciklama2 Asc;
select HataKodu3,HataAciklama3,Count(HataKodu3) as Toplam From Tablom Where HataKodID3<>0 group by HataKodu3,HataAciklama3 Order by HataAciklama3 Asc;
select HataKodu4,HataAciklama4,Count(HataKodu4) as Toplam From Tablom Where HataKodID4<>0 group by HataKodu4,HataAciklama4 Order by HataAciklama4 Asc;
how to 4 sql command to reduce 1 sql command?
Thanks
|
|
|
|
|
do it inside a procedure and execute the procedure
|
|
|
|
|
|
eraydeniz wrote:
That isn't very nice. The guy tries to help you and you respond with a MAD face. If the answer is not the one you seek then perhaps you need to ask a better question.
|
|
|
|
|
That was a fair suggestion show some respect sir.
|
|
|
|
|
Exactly, I don't understand the mad face for a decent response.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
eraydeniz wrote: how to 4 sql command to reduce 1 sql command?
That doesn't make much sense.
Depending on how that should be interpreted there are two answers I can think of:
You could UNION the results together to form one result set.
OR
You could just execute it all in on SqlCommand and get 4 result sets back, but it is sent as one SqlCommand.
|
|
|
|
|
Could You please provide me with solution
I have a panel and only one control on it - WebBrowser control. When I try to access to webBrowser.name is OK, but webBrowser.Url == null
WebBrowser webBrowser = webBrowserTabControl.SelectedPanel.Controls[0] as WebBrowser;<br />
webBrowsersCollection.SelectedWebBrowser = webBrowser.Name;<br />
currentURL = webBrowser.Url.ToString();
Thanks in advance
|
|
|
|
|
Have you browsed to a URL? If not, the Url property is going to be null. You should check this before calling the ToString() method on the Uri object instance.
Paul Marfleet
|
|
|
|
|
Thank for all
I created additional dictionary to collect URL, becouse it seems to me that WebBrowswer has URL property resolved after "web paged displayed", But I can't create additional thread to wait while it will be finised
-- modified at 8:29 Thursday 1st November, 2007
|
|
|
|
|
probably because it has no url set?
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
HI,
i've got a DataGridView to which i load data from a file.
i like to know how can i change the color of a cell (or the text)
the idea is :
when i load the data i check a certain cell an if it's Value <0 then i like
to see the (Value in a Red Color)
i'm using this kind of insert to the datagridview :
<br />
for(....)<br />
{<br />
string cColumn1 = value;<br />
string cColumn2 = value;<br />
.<br />
.<br />
.<br />
<br />
Object [] rRow = { cColumn1 ,cColumn1 };<br />
dataGridView1.Rows.Add(rRow);<br />
}<br />
THNKS in Advance
Have Fun
Never forget it
|
|
|
|