|
OK. I will use form2.show();
When i close this form and want to open it again it writes an error exception says: "Cannot access a disposed object. Object name: 'Form2'."
What do i need to do to make it work?
|
|
|
|
|
Can you post the code how you are doing this?
May be you are using a class level object for Form2 and calling Show method in button click event. You need to create object in the click event itself. Like this:
private void button1_Click(object sender, EventArgs e)
{
Form2 o = new Form2();
o.Show();
}
जय हिंद
|
|
|
|
|
Ok,
I wrote before the "Form2 form2 = new form2();" not in the method of opening the form (button method) but outside in the class .
If i write it in the method it works but the problem is when i click the button of this form opening couple of times it opens again and again this form2 (i have many form2 opened).
I thought to use "if..." to check if form2 is already open and this way it won't open it again and again.
But maybe there is another way to prevent it?
|
|
|
|
|
Use Application.OpenForms property to check if the form is already opened. If it already open, just bring that to front and set focus.
जय हिंद
|
|
|
|
|
Another question-
If i write the new form2 in a method (of the button to open this form),
how can i use form2 in another method- for example a method that will check if this form2 is already open? Because in the other method it doesn't see the declaration of form2.
|
|
|
|
|
Application.OpenForms will work in any method.
जय हिंद
|
|
|
|
|
hi all
i am developing windows application in c#.net.i am using Socket concept in that.i have used one datagrid . using socket i filled up my data in grid and also i m using timer to update data in some columns of the data grid
now my problem is when i click on to the column of grid and try to wite in that column textbox i get the error for cross-thread invalidoperation
can anybody help into this problem
thanks in advance
|
|
|
|
|
Hi,
use delegate to refresh your data.
cheers,
Elie.
dghdfghdfghdfghdgh
|
|
|
|
|
hi Elie
thanks for solution but
is there any other way of it?
just because i m refresing the data thru the function inclass and that function i called thruout the application
|
|
|
|
|
that function should be called from a delegate
so create the delegate in ur class and call it.
Elie.
dghdfghdfghdfghdgh
|
|
|
|
|
Ankit At Codeproject wrote: now my problem is when i click on to the column of grid and try to wite in that column textbox i get the error for cross-thread invalidoperation
Which thread created the datagrid? What timer are you using, System.Windows.Forms.Timer or one of the other ones?
|
|
|
|
|
GUI components can only be modified from the thread that created them. As Elie said, you need to create a delegate for the function that modifies your datagrid, and then Invoke it on the GUI thread. Normally I do it like so, although there's probably a better way to do it:
delegate ReturnType DelegateType(T1 arg1, T2 arg2);
DelegateType del = YourMethod;
ReturnType YourMethod(T1 arg1, T2 arg2)
{
if(InvokeRequired)
{
return Invoke(yourDelegate, new object[]{arg1, arg2});
}
else
{
return someValue
}
}
For more info, check out the MSDN Documention for Control.Invoke[^].
Dybs
|
|
|
|
|
Hello,
i've an application that use a commandbuilder and a dataset and a datarow for inserting a new record in the database,but while i am trying to insert Arabic values they appear like ????
is their any solution or should i use the insert statement with a prefix N before values.
my code look like this :
SqlConnection myConn = new SqlConnection(SqlManager.Instance.ConnectionString);
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.SelectCommand = new SqlCommand("select * from Exceptions", myConn);
SqlCommandBuilder custCB = new SqlCommandBuilder(myAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myAdapter.Fill(myDataSet);
DataRow dr = myDataSet.Tables[0].NewRow();
string b = "شسيس";
dr[1] = b;
myDataSet.Tables[0].Rows.Add(dr);
myAdapter.Update(myDataSet);
myConn.Close();
dghdfghdfghdfghdgh
|
|
|
|
|
Check these links: this[^] and this[^]. Might help you.
जय हिंद
|
|
|
|
|
i am using datetimepicker component for selecting dates.
and i will store that in string variable
(Eg: string date1 = renewalDTP.Value.Day + "/" + renewalDTP.Value.Month + "/" + renewalDTP.Value.Year;)
if i want to compare two dates how can done it....
|
|
|
|
|
Read up on the DateTime class and discover at least one method that yields a date difference, expressed as a TimeSpan.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I am having a problem with Tableadaperts. I am trying to insert a new record into the database using the Tableadapert.insert.
I have commented out // [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
and put a break point to see how the method runs every thing looks fine no exceptions. I get a return value of the record but the database table remains empty.
What am I doing wrong? The tableadaper is supposed to directly interact with the database?
private void button1_Click(object sender, EventArgs e)
{
try {
int val = 0;
tbUsersTableAdapter ta = new tbUsersTableAdapter();
val = ta.Insert("other1", "other");
//val retuns 1
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
|
|
|
|
|
I don't use the tableadapter but it seems to me you need to give it various bits of information, like the connection, insert statement, update statement etc. You seem to have created an adapter, thrown some data at it and expected it to magic the data into the database.
I suggest you do some reading/research before you cry for help, this issue has been answered MANY times and there are examples and tutorials out there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, all expert
I'm from Thailand.I interesting to know whether have any method to import pdf. file into whatever DBMS ?
Can import by coding or not ? Or only with third party control supplier? And what the control name to accomplished ?
Hope any expert give me clearify my doubt.
Regard,
Nont....
|
|
|
|
|
Hi All,
I wrote a Windows application using VS 2005 (c#). I made an installer by making a Setup and Deployment project and writing a corresponding installer class. There are a couple files I need to include with the program, which will be altered by the (installed) program during use. The issue I'm facing is that when I install the program (and files) and run the program...the files are changed, as I expect. I uninstall the program and reinstall the program and the files are not fresh...they contain the changed contents!
How I am including the files is by right clicking on MySetupProject -> view -> file system. I right clicked on Application Folder -> Add -> File.. Then I added each file to the Application folder. The files are added to the correct folders during installation and are removed during uninstallation.
I'm not sure what is happening. If anyone has an idea of what is going on or if I'm doing something wrong please let me know.
Thank you.
-choo_chu
|
|
|
|
|
Scenario : client server application. vb6 client side application to Microsoft SQL server database.
all clients have registry keys to provide odbc connection to a database holding available environments.
Once a user has selected the environment they require the specific odbc string is supplied from this master to the specific db for the selected environment and the master plays no further part.
Problem : because every user selects from the same list all connections are listed under the same user in SQL making life very difficult to resolve locking issues that occure.
The use of windows integrated logins is not possible as i have no access to the application code and we need to prevent r/w access to the environment databases from say office applications.
Solution : I am therefore considering implementing a wrapper for the client application to generate individual sql logins and account in the master DB so that the connections can then be distinguished in SQL.
The wrapper will need to talk to a service that will have the relevant sql access to create / disable / enable the logins.
Question : with all this said can I please have relevant pointers / ideas / examples to first create this service that will need to talk to SQL via a dedicated admin account and also to clients on the network probably via IP using again probably XML.
I am not looking for spoon feeding as I enjoy learning in this hands on method just places to go / articles and examples that explain principles that I can then adapt.
Thanks for the assistance
Bryden
P.S I do realise that this will not be a walk in the park and that I could probably have posted this on a number of different forums but I plan on using c# unless advised differently.
|
|
|
|
|
Your core issue is managing the locking issues, probably identifying the culprit PC so you can go thump the user. I know when we use OLEDB the workstation id is in the connection and can be seen in Profiler, I don't know if ODBC supplies this info. We then have an internal register of PC/User so we can find the transgressor, what I really want is a remote reboot
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes ODBC does provide the workstation ID.
Life becomes more complex however when the client is a terminal / citrix server then all users also have the same client.
I have another way around this by interogating sys.sysprocesses and lokking up not only the hostname but also the hostprocess columns.
The hostprocess number equates directly to the process id that can be seen in task manager or terminal server manager to identify the user.
The main point of this is that I think my solution would make life easier for my customers and allow me to learn a lot more about c#.
I do know where your coming from though with the remote reboot although a sledge hammer is sometimes more appropriate!
|
|
|
|
|
Bryden.Murdoch wrote: allow me to learn a lot more about c#.
I seem to have got the goals mixed up , this one I can relate to.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|