|
i solved it by another way
form1
form2 f2 = new form2();
f2.showdialog();
f2.dispose();
if(f2.IsDispose)
{
textbox1.text = valuetext;
}
// value text is static variable in form2
thank u for ur replay
|
|
|
|
|
DO NOT DO THAT!
See here[^]
When you dispose a control, you have no control over when it's memory is available - the garbage collector is a liberty to remove it at any time. The code may work now, in testing, and then fail intermittently for no apparent reason later.
To add to that: What do you think static variables are? Again, this will cause you problems. Read up on the difference between a STATIC and a PUBLIC variable.
Also, it is considered bad practice to expose fields directly, and it makes it difficult to implement changes later. Use a property instead.
To add to the list: Don't use f2.ShowDialog() alone - always surround it with an "if" as in:
if (f2.ShowDialog() == DialogResult.OK)
{
...
} Otherwise, what happens if the user decides he doesn't want to enter a value?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
|
OriginalGriff wrote: When you dispose a control, you have no control over when it's memory is available - the garbage collector is a liberty to remove it at any time. The code may work now, in testing, and then fail intermittently for no apparent reason later.
The garbage collector cannot remove a disposed control if any references to it exist. If there are any user fields or properties, within a control, those fields will continue to be valid, even after the control is disposed, with the exception of properties that explicitly check for isDisposed and will throw exception exception if it is set.
As for the best way to return the content of a form that is invoked modally, I would suggest that rather than using events, one (1) define a class which contains the form's contents and an enumerated type listing methods of exit; (2) define a method in the form which will ShowDialog itself and then return an object of the class in '1' filled with the values from the form; (3) define a static method in the form which will create a new instance, call the method in '2', and dispose of the instance. That would avoid any excess dependencies between the child form and the main form, and avoid having to add any extra code into the calling form.
|
|
|
|
|
Hi,
I have an outlook plug-in and it is working fine, but I have one issue there are few buttons and I am trying to use icons/ images on buttons with text content.
Please let me know how to use icons/images for buttons in Outlook plug-in.
Thanks.
|
|
|
|
|
Hi,
You can use FaceId properties for add image in your button. For example
_objNewToolBarButton.Caption = "My ToolBar Button";
_objNewToolBarButton.FaceId = 65;
For more, visit Outlook 2007 Add-in Using Microsoft Visual C#.NET[^]
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hi all,
I've been trying to solve this problem for over an hour and as I'm a rookie I know that what I want to do is easy to implement, but my lack of experience is preventing me from doing so. With that said, I have some code for a ZedGraph dynamically updating control. Notice that the variable double time controls the x Scale. This code is executed in a timer tick event in order to draw the line on the graph. However, as the x-scale is driven by Environment.Tickcount (which is totally independent of the timer) the graph x-axis increments regardless of whether the timer is enabled or not. I want the double time to be replaced with a double that is based upon the elapsed time of the timer and not the Environment.TickCount, but I can't figure this out. Maybe because I'm too tired... Thanks in advance for any help.
if (zedGraphControl1.GraphPane.CurveList.Count <= 0)
return;
LineItem curve = zedGraphControl1.GraphPane.CurveList[0] as LineItem;
if (curve == null)
return;
IPointListEdit list = curve.Points as IPointListEdit;
if (list == null)
return;
double time = (Environment.TickCount - tickStart) / 1000.0;
list.Add(time, dblLabel);
Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale;
if (time > xScale.Max - xScale.MajorStep)
{
xScale.Max = time + xScale.MajorStep;
xScale.Min = xScale.Max - 30.0;
}
zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();
|
|
|
|
|
Just set up:
private double myTime = 0.0; as a class field.
In your Load event or constructor:
Timer tim = new Timer();
tim.Interval = 1000;
tim.Tick += new new EventHandler(timer_Tick);
tim.Start(); And add the Tick event handler:
void timer_Tick(object sender, EventArgs e)
{
myTime+= 1.0;
}
However, it may be easier and better to save the start time as a DateTime; and subtract it from DateTime.Now in your update method. You can then get the elapsed seconds from the resulting TimeSpan.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
|
You're welcome!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I am getting a Disconnected Context Error when I execute my code which basically programmatically creates an Excel spread sheet.
What is the reason for this and how do I fix it?
Thanks
Tim
|
|
|
|
|
I am having the same trouble as well, and actually with the Excel COM object. just opening and writing to spreadsheets.
It is doubly weird because I am running the same code on my windows xp machine at work - no problems.
I run it at home on my windows 7 machine and I get the disconnected context error.
I am not using any fancy multi-threading.
Running VS 2010
Any help on this issue would be much appreciated. I am pretty stuck.
|
|
|
|
|
i have write a code for haar wavelet transform but i coudn't input image to its inverse transform any body can help me!
modified on Friday, April 16, 2010 4:38 PM
|
|
|
|
|
Do not Repost.[^]
This same question was down voted yesterday, you should have found out why it was down voted and rephrased the question. Since you are new to code project, you are excused.
No one understands your question. What have you tried and what doesn't work? What do you mean by I couldn't input image? Which API/method are you using and what failed when you try to pass the image?
If you find it tough to write your question in english, use Google translate[^] to help you figure out what you want to type.
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
How to Make textbox autocomplete?
|
|
|
|
|
Set the TextBox 's AutoCompleteMode , AutoCompleteSource and AutoCompleteCustomSource Properties to appropriate values depending on what exact behavior you wish it to have.
MSDN[^]
|
|
|
|
|
i changed AutoCompleteMode ==>suggest
Autocmpletesource ==>Customersourc
In foreach (DataRow row in (SelectAccounts().Rows)
{
textBox1.AutoCompleteCustomSource.Add( row["Account_Name"].ToString());
}
it worked successfuly and displayed names in table Account
now i want to get id for accountname that user enter
SelectAccounts() return table accounts{id,Account_Name}
|
|
|
|
|
OK, so loop through the rows again until you find the one where the account name matches what they entered in the TextBox and then grab the ID from that row. If you want to get fancy about how you do it then you could probably do it using Linq but looping and searching will work just fine.
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
If anyone is familiar with Delphi and it's TADOQuery component, I would like to do something similar to the TADOQuery.Locate method.
If your not familiar with Delphi's TADOQuery.Locate, I want to be able to programatically select a newly added row. So the user can have a visual reference that a post was successful.
I read online sometime a ago that the TableAdapter.Select() method was the way to go but I can't seem to get it to work. Anyone?
I found this answer here
http://www.akadia.com/services/dotnet_find_methods.html
but it requires your tables to have primary keys and just my luck none of my tables have primary keys. By the way I didn't create these tables. How do I do the find without primary keys? I don't want to have to add them to all my Tables.
modified on Friday, April 16, 2010 4:53 PM
|
|
|
|
|
I am making a couple of assumptions here that may or may not be accurate. 1. Your datastore is a SQL database 2. You have no identity column (primary key is one type of identity column).
Without an identity column defined, SQL databases methods to return the last inserted record (@@identity or Scope_Identity()) will return NULL. Soooo you need another way to skin that cat.
One way, and there could be many options would be to make a clone of your current datatable before refreshing the data from the database and then compare the records to find the new one.
A way to do that would be something like:
datable1.merge(datatable2);
datatable3 = datatable2.GetChanges();
Then you could find the row or rows from datatable3 in your table and make that or them your current selection.
Hope this is helpful.
|
|
|
|
|
It's an SQL Server database and we do have identity columns but they are no primary key columns. I am able to use @@Identity and Scope_Identity() in the Delphi App and it works fine. I just need to figure out how to do it in C#.
|
|
|
|
|
This may work for you assuming you are dynamically generating your sql and submitting through an ADO query object.
Add a statement such as "Select Scope_Identity() From Table MyTable;" to the end of your dynamic sql. Then instead of submitting as ExecuteNonQuery(), run it as a regular query and the return value should be the row you added.
ymmv
|
|
|
|
|
I'm sorry I'm taking so long to reply to this thread, I'm a little busy. Ok so everything you said works but now how do I select the newly added row. I've tried several ways so far. e.g. this.bindingsource.contains(NewID), this.bindingsource.find(NewID). this.bindingsource.FindRows(NewID). But they never select any row except the very first row.
|
|
|
|
|
After searching long and hard I finally found a way to do it. Makes me wonder why I didn't think of this before.
for ( int i = 0; i < GridContact.Rows.Count; i++ )
{
if ((int)GridContact.Rows[i].Cells[1].Value == ID )
{
GridContact.ClearSelection();
GridContact.Rows[i].Selected = true;
}
}
|
|
|
|