|
Why start over every time you find a row? Just store the rows you want to delete, and do it separately.
List<DataRow> removal = new List<DataRow>();
foreach (DataRow row in dataset.Tables["grant"].Rows) {
if ((int)row["principal_Id"] == nPrincipal_Id) {
removal.Add(row)
}
}
foreach (DataRow row in removal) {
row.Delete();
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Well, none of your solutions work. most give errors. Maybe guffa's will, if he get's his code working (<DataRow> <--- what's this supposed to be).
|
|
|
|
|
Templating. a C# 2.0 feature.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Bummer8 wrote: Maybe guffa's will, if he get's his code working
Gets HIS code working?? Who getting paid to write the code?? Hint, it's NOT Guffa...
Guffa's code works, for .NET 2.0 and above. Apparently you're using .NET 1.1 or below. Colin's will work on .NET 1.1. In either case, they both will work, based on the very limited information you've given. It's up to you to apply the concepts demonstrated to your exact situation.
Buddy, that is what you're getting paid to do!
BTW: Your code looks like it's trying to enforce referential integrity in a database. This is something that's better left up to the database itself.
And, I haven't used a Goto for any reason what-so-ever, in any language, in, what, the last 12 years...
|
|
|
|
|
Hey!
I am trying to set the Enable-property of a toolstripstatuslabel on a statusstrip through an event and I am getting the error message "InvalidOperationException was unhandled, Cross-thread operation not valid....".
On other controls I would solve this by using the control.BeginInvoke() method but there is no such method for a toolstripstatuslabel.
I yes, I want to have CheckForIllegalCrossThreadCalls set to true.
Anyone who has an idea how to solve this?
|
|
|
|
|
I'm not sure what you're taking about but it seems like you want to disable some tool tips from appearing which can be easily archived by excluding them from your controls and adding them again once needed so focus on the associated control not the tooltip itself
and...
Hampus@foi wrote: CheckForIllegalCrossThreadCalls
Is a bad practice in threads so try to skip it by all means!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
can u pl tell me how to implement custom desktop thro' c#? i want to customize desktop on lan machines..
|
|
|
|
|
You can do it by editing the right registry values, however, for most changes to take place, the user will have to restart.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
define custom desktop?
Custom like in Linux KDE GNOME and X-Windows, completely different desktops that are applied as a visual layer to the underlying operating system?
or Custom as in you choose which icons/shortcuts/privileges you permit the users to use?
"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
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
How to disable the Automatic ToolTip Of TreeView in C# (2003)
venki
|
|
|
|
|
How about TreeView.ShowNodeToolTips=false; ?
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 got this very simple code, now it only works once then it crashes.
If i havent overlooked anything its becuase evertime the OnIncomingMessage event is called it creates a new filestream and streamwriter but i have no idea how to fix this.
It has to create a file, write the message, close the file making it accessable to other programs.
And then when the event is fired again it should do it all over.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Messenger;
using System.IO;
namespace msnincoming
{
public class msnincoming : IMessengerAddIn
{
private MessengerClient _client;
private string _message;
private FileStream _test;
private StreamWriter _test2;
#region IMessengerAddIn Members
public void Initialize(MessengerClient messenger)
{
_client = messenger;
_client.AddInProperties.FriendlyName = "Incoming message alert";
_client.AddInProperties.Creator = "Scale";
_client.AddInProperties.Description = "Alerts Announcer! of new messages";
_client.IncomingTextMessage += new EventHandler<incomingtextmessageeventargs>(this.OnIncomingMessage);
}
#endregion
public void OnIncomingMessage(object sender, IncomingTextMessageEventArgs e)
{
_message = e.UserFrom.FriendlyName + " says " + e.TextMessage;
_test = new FileStream(@"c:\MSNinc.txt", FileMode.CreateNew);
_test2 = new StreamWriter(_test);
_test2.WriteLine(_message);
_test2.Close();
_test.Close();
}
}
}
Thanks!
|
|
|
|
|
MSDN says: "CreateNew: Specifies that the operating system should create a new file. This requires FileIOPermissionAccess.Write. If the file already exists, an IOException is thrown"
You should read the documentation on the types you plan to use!
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
|
|
|
|
|
Doh, I tought it was that it was trying to create another instance of the streamwriter.
I hate class libary's :P i love debuging.
Thanks!
|
|
|
|
|
Hy,
Can you put in a switch statement anything else besides basic types...i mean can you do something like:
DataColumn dt;
switch(dt)
{
case ...:
case ...:
}
Thanks.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
No, integral types only (string,int,short,decimal etc)
|
|
|
|
|
Thanks. Back to the drawing board :->
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
You can as long as the type you are using can be evaluated to a numerical value.
================================
Wirth's law: Software gets slower faster than hardware gets faster.
|
|
|
|
|
hi
i create an application with C#.
now i want to go on my develop in another computer but when run my application without any change , at run time , before main form show, throw following Exception :
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))<br />
i really don't know how can resolve it.
i think my problem is for dll references that i use in my application !
can i "reference to dll with "reference path" tools in my application property ?
can you help me.
tanks
|
|
|
|
|
I'm not so sure but I think u must be using COM here and the component your app is trying to use is not there in the registry.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
thanks.
how can i registry COM in my application ?
|
|
|
|
|
well personally I hadnt had enuff exposure of COM but I've seen such issues comming at a few places,
generally I've seen ppl registering the required DLLs but for that you gotta know which dlls your application is using. RegSvr32 is a command you should search out for, its used in command prompt by the way. I hope its a bit helpful to u:->
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Hi,
I currently do the following when closing a form containing editable databound controls (comboboxes mainly)..
this.configBindingSource.EndEdit();
if ((bool)this.myDataSet1.HasChanges())
// do some stuff
The problem is that if I bind a control's tag to a field in the datatable, the above condition is met even if there are no changes made to the form's controls at all. Even if I bind it to a label.tag, it still triggers a change to the datatable.
Is there something I'm doing wrong?
Thanks.
Glen Harvy
|
|
|
|
|
No you're not doing something wrong, but you have to know something about data binding:
Whenever you bind something to a property (Tag in your case) that does not have a corresponding PropertyChanged event (TagChanged event in your case) then the data binding framework assumes that the value has changed. Therefore the value is written back to the data source even if the value hasn't changed.
If this is the reason for your problem then you can:
- define that the binding is only unidirectional (from data-source to control and not back). This can be defined somewhere, but I can't remember where (we don't use data binding anymore)
- derive a class from that control and implement the TagChanged event
- use something better than data binding (MVP)
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Thanks for that - in this case I'll handle the situation differently.
Glen Harvy
|
|
|
|