|
Hi,
Think i've solved it. I was building up a collection of controls which wasn't needed because i can use the this.Controls collection instead. Seems to be working fine now as i can have 20 odd forms open and it doesn't crash.
Regards,
Gareth.
|
|
|
|
|
Hi all,
i'm preparing an exe where i have to get the records from the dataset and display in the listbox.
when there is records then everything is good, when there is no records returned then i have to check the condition in the form load event and i have to close the exe.
this exe will autorun in an installer.
when i close the form in form_load event then the program.cs file is throwing error.
public partial class frmChkStatus : Form
{
public string ConString = string.Empty;
public frmChkStatus()
{
InitializeComponent();
try
{
OdbcConnection strCon = new OdbcConnection();
strCon.ConnectionString = "DSN=STUSTATUS;LOGINID=STU;PWD=ANY";
strCon.Open();
string strExamCnt = "Select DISTINCT ME.stu_NB from MBR_STU ME where Me.STATUS_FL = UPPER('Y')";
OdbcCommand myCommand = new OdbcCommand(strExamCnt, strCon);
DataTable dt = new DataTable();
OdbcDataReader reader = myCommand.ExecuteReader((CommandBehavior.CloseConnection));
dt.Load(reader);
if (dt.Rows.Count <= 0)
{
//lblResult.Text = "No Records Found";
// Application.Exit();
ActiveForm.Hide();
//lstExamCodes.Visible = false;
}
else
{
//lblResult.Text = dt.Rows.Count + " Records found";
lstExamCodes.DataSource = dt;
lstExamCodes.DisplayMember = dt.Columns[0].ColumnName;
}
}
catch (Exception ex)
{
MessageBox.Show("Exception occured while retrieving STUDENTS.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
frmChkStatus.ActiveForm.Close();
}
}
}
PLEASE LET ME KNOW HOW TO CLOSE THE FORM WHEN THERE IS NO RECORDS AND CONTINUE TO OTHER INSTALLERS EXECUTION
M.MohanVamsi
|
|
|
|
|
Your code looks fine to me. I compiled it and ran it just fine. What error is being thrown?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
This is the winforms application.
i'm getting error in program.cs file.
when i close the form it is giving the following exception.
System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'frmChkStatus'."
Source="System.Windows.Forms"
ObjectName="frmChkStatus"
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CheckStatus.Program.Main() in C:\Documents and Settings\MedikonM\My Documents\Visual Studio 2005\Projects\CheckStatus\CheckStatus\Program.cs:line 22
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
in short the exception is
ObjectDisposedException was unhandled.
Cannot access a disposed object.
Object name: 'frmChkStatus'.
M.MohanVamsi
|
|
|
|
|
Application.Run(new frmChkStatus());
during this peice of code i'm getting error. this code is in program.cs in static void Main()
M.MohanVamsi
|
|
|
|
|
Ok. Looking at all the code in the OP, all that code was in the forms constructor. What does your code for closing the form in frmChkStatus_Load look like?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
there is no code in the form load event. initially when the form loads itself it has to connect to database and check whether there is any records or not.
if there is no records then exe has to close with out loading the form.
that is my requirement.
M.MohanVamsi
|
|
|
|
|
Hi
I have a form which is being used by a user to send an e-mail.
the problem I have is thta if a user clicks enter whilst in the textbox(message) then the e-mail form is submitted.
Bascially when they press enter I want them to be able to move onto the next line of the textbox not send the message
cheers
|
|
|
|
|
You need to set both Multiline and AcceptsReturn to true .
Hope this helps.
Matthew Butler
|
|
|
|
|
when i try that in c# it says that the textbox does not contain a defintion for accepts return
code:
tb_message.AcceptsReturn = true;
any more suggestions?
|
|
|
|
|
I'm not sure why it doesn't exist: (I've just tried it successfully compiling under .Net 2.0).
I am assuming when you say 'TextBox'... you are refering to System.Windows.Forms.TextBox not a System.Windows.Forms.RichTextBox .
If you are using a RichTextBox:
On the form (where the enter button is) there will be a property called AcceptButton ... set this to null.
Otherwise I can't help you.
Matthew Butler
|
|
|
|
|
its using System.Web.UI.WebControls;
is this what you mean?
its not a richtextbox
thanks so far
|
|
|
|
|
In that case:
tb_message.TextMode = TextBoxMode.MultiLine;
This should work. (But I've never used web controls so it might not).
Matthew Butler
|
|
|
|
|
hi that worked!!
but how would i use: AcceptsReturn
i cant find the right bit of code that works for web controls
thanks so far!!
|
|
|
|
|
AcceptsReturn is only for System.Windows.Forms.TextBox (not Forms.RichTextBox or the WebControls.TextBox).
Setting TextMode to MultiLine should be the only thing you need to do.
Matthew Butler
|
|
|
|
|
no I am afraid that doesnt work, the form still sends even if i put in the bit of code you posted, thanks anyway i will keep trying
|
|
|
|
|
HI, I am new to C#. I am working on a software that uses oracle as its database. As I am new to this environment It is getting difficult for me to find things out.
I have connected to my database in Oracle which name is DBA.I can add ,delete, update data now.But I am facing difficulty to retrieve values of next row or previous row or first row or last row.
It would be really helpful for me if any one can tell me what code should I write under those four buttons.
|
|
|
|
|
Saiyed Alam wrote: HI, I am new to C#. I am working on a software that uses oracle as its database. As I am new to this environment It is getting difficult for me to find things out.
I have connected to my database in Oracle which name is DBA.I can add ,delete, update data now.But I am facing difficulty to retrieve values of next row or previous row or first row or last row.
It would be really helpful for me if any one can tell me what code should I write under those four buttons.
I am not sure I understand your problem. Are you getting your row directly from your database? Or are you populating your table into a DataTable in C#? If you are not loading your rows into a DataTable I recommend you do that.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi, thank u, I meant I am failing to watch the values of the table. I want to show the values of each row in separate text boxes. How can I do that?
|
|
|
|
|
i need to make method pass number integer as 3 and print on screan 3 2 1 0 1 2 3
but not use loop at the method and not return any value
123
|
|
|
|
|
Well, you could do this:
private void PrintNumbers(int number)
{
Console.WriteLine("3 2 1 0 1 2 3");
} And then call it with PrintNumbers(3);
Alternatively, you could do this with a recursive method call.
|
|
|
|
|
Pete O'Hanlon wrote: you could do this with a recursive method call
a recursion with a method that "does not return a value"?
so a class member would be used to make things ugly. What will they come up with next?
|
|
|
|
|
It's quite possible to solve this in a recursive manner without having to use return values or class members.
To the Original Poster: I'm guessing the whole point of this exercise is to demonstrate that you understand recursion. If you don't, then it's probably worth re-reading your course notes, as you won't learn anything if we just tell you the answer (which is incredibly simple.)
|
|
|
|
|
but you don't know what number maybe 3 or 4 or 18 ...etc
123
|
|
|
|
|
It's not my fault that your specification was vague. You asked " need to make method pass number integer as 3 and print on screan 3 2 1 0 1 2 3
but not use loop at the method and not return any value" and I gave you a method to do that. I'm not responsible for your scope creep.
|
|
|
|