|
Yes thats what i thought about too, two processes that watches eachother (like some trojans do). But ZoneAlarm uses something to prevent their process from being killed. I though about one more way to do it, like rootkit does, hiding it from being seen in any process manager.
|
|
|
|
|
The thing I want to do is simple: bind Control to String... so I must be missing something obvious... here's code:
[code]
string stringDataSource = "Hello";
private void Form1_Load(object sender, EventArgs e)
{
textBox1.DataBindings.Add("Text", stringDataSource, null);
}
private void btnWork_Click(object sender, EventArgs e)
{
MessageBox.Show(stringDataSource);
}
[/code]
Tnx
|
|
|
|
|
Since strings are immutable in .NET, this shouldn't work. A string is never changed. When a string reference points to a new value, it is literally pointing to a new string in the string pool (i.e. it points to a different memory address). Plus, databinding requires that you bind to a property, not to a value directly. Expose your string as a property on another object and then bind to that object & property.
Josh
|
|
|
|
|
First of all, tnx a lot Josh... I surely better understand whole thing now.
On another matter -> is it possible to bind to a member of Collection? If I'm having this situation:
<br />
public class ModificatorData<br />
{<br />
private List<String> address;<br />
public List<String> Address<br />
{<br />
get { return address; }<br />
set { address = value; }<br />
}<br />
}<br />
Is it possible that I say -> textBox1 bind to first member of Address collection... textBox2 to second member... and so on?
I guess answer is no because it's what DataGrids and DataSets do and you can't easily expose every member as Property, but I'm still courious...
Again -> tnx for your help
|
|
|
|
|
Technically, you could have each textbox bind to a different element in a collection, but that isn't the intended use of simple databinding. Simple databinding (binding a control property to a data source property) is meant to allow multiple controls on a Form to display the various values found in one object (i.e. one Address object in a collection).
The "current" object being bound to in a collection is scoped to a BindingContext. Each control using the same binding context (which is the default set up) will display a value from the current item. If you really want each textbox to display a value from a different address, you'd need to establish the binding for each control in a separate binding context. Then move the currency manager's current object in each binding context to set the "current" object for that control. Sound like fun?
Josh
|
|
|
|
|
DataSet + DataGrid is much easier
Tnx a lot for your help.
|
|
|
|
|
In my database i have field called bit but when i attach this table with datagrid it display this field as true and false
but in datagrid i want to display this as Y or N
so please tell me that how it is possible
|
|
|
|
|
You can accomplish this by using the following technique:
enum YesNo
{
Y,
N
}
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable tbl = new DataTable("testTable");
tbl.Columns.Add( "bit", typeof(bool) );
tbl.Columns.Add( "Y/N", typeof(YesNo) );
tbl.Rows.Add( new object[] { true, YesNo.Y } );
tbl.Rows.Add( new object[] { false, YesNo.N } );
this.dataGrid1.DataSource = tbl;
tbl.RowChanged += new DataRowChangeEventHandler(tbl_RowChanged);
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = "testTable";
this.dataGrid1.TableStyles.Add( style );
style.GridColumnStyles.Remove( style.GridColumnStyles["bit"] );
}
private void tbl_RowChanged(object sender, DataRowChangeEventArgs e)
{
if( e.Action == DataRowAction.Change )
e.Row["bit"] = ((YesNo)e.Row["Y/N"]) == YesNo.Y;
}
Using the YesNo enum makes the grid automatically validate the text entered by the user, which it would not do if the column were a string datatype.
Josh
|
|
|
|
|
Dear Professionals
Could you Answer my question about .NET i have created a windows application that creates user defined objects every 2 seconds
these objects includes Dataset and XML ,I create them inside the scope of the function not in global scope , after running my application for one hour i got an exception from .NET Framework saying (MemoryOutException)
According to microsoft GC wouldn't destroy objects even if they are out of scope:
So U need to implement IDisposable interface and Dispose these objects in your code to ensure that the objects will destroyed instantly
is that what happened really
or the object will still in memory even if you used Dispose method for them until GC take care of them
agmb
|
|
|
|
|
To be honest I'm not suprised you got an OutOfMemoryException if you created 1,800 DataSets, the DataSet is a powerful class and with power comes size.
If your just parsing xml stuff then I'd suggest using an XmlTextReader object since they lighter on memory.
The GC will destroy objects when it has time to and when it knows ( ) that there is no chance of them being referenced. There is a method which can be called to force a Garbage Collection but can't remember it off the top of my head right now since I've never used it.
All that the IDisposable interface does is make sure that the GC calls the Dispose method so that the class can release unmanaged objects (and perform some proper destroying in a logical order).
I'd have a good think about what's the best way to tackle your problem since creating 1,800 datasets is shall I say a somewhat unique problem.
Hope this helps a bit
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Maybe you can look into Object.Finalize (See MSDN)
Good luck
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
Any object that implents IDisposable has to be disposed to be up for garbage collection.
If your object contains other objects that implements IDisposable, your object should also do so, in order for your object to be able to dispose the objects that it contains.
When implementing IDisposable you should also implement a finalizer. That keeps most memory leak accidents from happening. If the garbage collector finds objects that could be collected but are not disposed correctly, it will call the finalizer to make the object dispose itself. If the object has no finalizer and the inner objects are not referenced from elsewhere (so they can be disposed), the object can never be collected.
MSDN: IDisposable interface[^]
---
b { font-weight: normal; }
-- modified at 13:14 Thursday 27th April, 2006
|
|
|
|
|
Is it possible to have two columns from the datasource in the checkedlistbox.displaymember?
This is what I want to accomplish but it doesn't work:
ListBox1.DataSource = column1
ListBox1.DisplayMember = "column2" + "column3"
|
|
|
|
|
If you can override the ToString() method of the object or create a new readonly property which can serve as a display member.
An alternative would be to handle the OnDrawItem event to draw the string as you want it.
In short: there is no magic property which can do it for you.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
I'm developing some MDI applications using VS 2005. I'm wondering if anyone knows of a way I can prevent control validation events from firing if the user clicks on the controlbox close button to exit an MDI child form? Or, as an alternative, if there is a programmatic way to capture the clicking of the controlbox close button before any validation events have fired? I do not want to set CausesValidation on all of the controls to false, and I would prefer to not disable the controlbox close button.
Thank you...
|
|
|
|
|
to catch form close event use Closing Event
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(CanClose == true)
e.Cancel = false; //when this is set to false form closes
else
e.Cancel = true; // when this is set form does not close
}
Shajeel
|
|
|
|
|
Thanks but I have no problem with catching the form close event, what I would like to do is prevent validation events from being fired when a user clicks on the Control Box close button. By the time the FormClosing event is triggered, the validation events have already happened and I want to avoid that when the ControlBox close is clicked. As an alternative if there is a way to catch the event/message that the user is clicking on the controlbox close button, that too would help me with some validation issues.
|
|
|
|
|
follow the link code is not given but it tells you which messages to catch.
http://www.dotnet247.com/247reference/msgs/7/35820.aspx
Shajeel
|
|
|
|
|
Hi everyone.
I'm developing a Windows Forms MDI application with several forms and user controls inside these forms. In some Error situations the user controls display a MessageBox with some text to the user, indicating the error.
The problem in showing these messages is that after I exit the messageBox window and go back to the application window, some of the ComboBoxes on the user control stop working. They just don't respond to any event, like SelectedIndexChanged for ex.
Any clues? Thanks in advance.
The messageBox display is done like this:
try
{
}
catch(Exception ex)
{
MessageBox.Show(null, ex.Message, "Data Error");
}
and i've also tried (with this refering to the user control):
MessageBox.Show(this, ex.Message, "Data Error");
|
|
|
|
|
You need to be a bit more specific about
joaoafonso wrote: //code to treat user's choice
I'm guessing that you need to revert the combobox back to it's previous or default value, you're probably leaving it with an erraneous value.
(I'm just guessing mind)
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
ok, maybe I need to be more specific...
The code tag where I said the user's choice was treated, isn't called when the selectedIndex on the comboBox changes. Instead there is a Button on the User Control to save some info users enter on several textBoxes, and in case there's an error/exception the MessageBox is displayed in the catch{}.
In some cases the combobox retains its values, I can chose them but the selectedIndexChanged event isn't fired. In other cases the comboBox stops working and doesn't open when I click the drop-down arrow. If I don't display any MessageBox the problem never occurs. Happens only after a messageBox is displayed.
Maybe something happens when the MessageBox closes? Is there some event that is fired? Anyone knows what happens to a messageBox object after the window closes?
|
|
|
|
|
Hmm, if the MessageBox.Show is the only code in the catch block then it's puzzling to say the least. Is there a way that you can check the values without having to check for an exception.
For example rather than doing (this is just an example mind):
try
{
MessageBox.Show(this.listBox.Items[0].ToString());
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
Which would display an error if there is no item at index 0.
Check first:
if (this.listBox.Items[0] == null)
{
MessageBox.Show(@"No item at index 0");
}
else
{
MessageBox.Show(this.listBox.Items[0].ToString());
}
Is that possible, can you validate the combo-box rather than wait for the code to fail?
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
It didn't work either... Does exactly the same as when I catch the exception. I still think there's something happening when the MessageBox is closed, some value being passed to the parent form, or even the MDI form (the parent form's parent), but I'm just guessing now
I've decided to build a form to display the error messages instead of the messageBox, since I have no clue as to why this happens.
This is really really weird. Maybe later if I have enough time, I'll try to reproduce this on a new MdiForm and put it here for anyone interested in testing it.
Thanks a lot for your help Ed!
I'll be posting any developments I have on this...
|
|
|
|
|
I've had a look through the MessageBox.Show code in Reflector and there doesn't seem to be anything obnoxious there. Maybe if I had more to play with I could solve it but get your coding done first, thats the main priority, then we can tackle MS
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
How can i use a masked textbox column in a datagridview for date
================================================================
I am working with Visual studio 2005 and c# 2005.
I have a datagridview which contains a date column and will accept value as 26-04-2006.Initially value will be 00-00-0000.When we press any key it will check value which we entered is number or not.if it is number then it will check for other conditions like
1 the day is greater 32 or not?
2 the month is greater than 12 or not?
3 the year is greater than 2006 or not?..like that.
we have to find in keypress event and cancel each character if it fails.
when we do backspace each value must changed to zeros..
I used masked textbox in datgridview for this but i am facing so many issues for that..
When we editing it will not work properly..the values are getting overlapped with the grid contents and all..i created the masked textbox dynamically in editcontrolshowing event..
if anybody did the same pls help me it is very urgent..
If you have any other solution that are also welcome
thanks in advance,
lee ju
|
|
|
|