|
Yeah, I noticed that. Thanks for pointing out.
|
|
|
|
|
I want to write a project in windows application with C#.net,
I have two forms , in Form1 i have a textbox, in form2 i need the textbox which is on Form1 , I want to know what should i do that form2 recognizes form1, how can i link these two forms??
|
|
|
|
|
It depends on the 'relationship' between the forms.
Scenario 1:
form1 instanciates form2
If form1 wants to send data to form2, you should write a public property with at least a setter (or a public method) in Form2. form1 can then set that property (or call that method) in the form2 instance.
If form2 wants to send data to form1, you should write an event (or raise a built in one) in Form2 and subscribe to it accordingly in Form1.
Scenario 2:
form1 and form2 are both instanciated elsewhere
Pretty much the same as above, except treat both forms like Form2s, and treat the object that did the instanciation like form1.
Reasoning:
The instanciating object already knows about any objects it's created (and can maintain a list of them if necessary). It therefore already has access to their properties, methods and events.
The created instances know nothing about the object that created them (and it should remain that way), so they should raise events that the creator can subscribe to, and if needed, the creator can cascade relevant data to other objects.
This applies to all objects, not just forms.
Note
Any event data should be passed through an instance of a class that you derive from EventArgs.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Well described 5'd
|
|
|
|
|
Well, you can do that but why you need to do that?
use mdi parent forms instead or use usercontrols like pages in your application.
I see no use of creating 2 form when you can do any of the methods above, but you are the boss...
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Even seperate user controls or MdiParent/MdiChidren should use the same method of communication. They are still seperate objects.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Timestamp: 1/24/2009 7:33:57 AM
Message: Exception in call me method : Thread was being aborted.
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
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.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at ANAX_Dashboard.AnaxDashFrm.Callme() in E:\ANAX Dashboard working folder\ANAX Desktop Reports\ANAX Desktop Reports\FrmAnaxDashboard.cs:line 95
Category: Error
----------
when thread is abort
|
|
|
|
|
Post some code so we can analyze it a bit.
|
|
|
|
|
I thing, ManualResentEvent or AutoResendEvent are used in ur application.
but u r not handle write.This is my assumption.
|
|
|
|
|
anishkannan wrote: I thing, ManualResentEvent or AutoResendEvent are used in ur application.
but u r not handle write.This is my assumption.
DO NOT USE TEXT-SPEAK. It's RUDE.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi
Anybody help me......
how can create table layout on the panel.
A one panel split in to row and coloum and each table have the
unique name. futherly we want to access that panel table name wise.
Thankyou
|
|
|
|
|
Timestamp: 1/24/2009 7:30:50 AM
Message: Exception in call me method : Form that is already visible cannot be displayed as a modal dialog box. Set the form's visible property to false before calling showDialog.
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at ANAX_Dashboard.AnaxDashFrm.Callme() in E:\ANAX Dashboard working folder\ANAX Desktop Reports\ANAX Desktop Reports\FrmAnaxDashboard.cs:line 95
Category: Error
|
|
|
|
|
Happens for example if you call Show for a form and afterwards you try to call ShowDialog for the same instance. But without seeing the code, it's hard to say more.
|
|
|
|
|
Timestamp: 1/23/2009 11:56:54 AM
Message: Exception in call me method : Thread was being aborted.
at System.Drawing.SafeNativeMethods.Gdip.GdipImageSelectActiveFrame(HandleRef image, Guid& dimensionID, Int32 frameIndex)
at System.Drawing.Image.SelectActiveFrame(FrameDimension dimension, Int32 frameIndex)
at System.Drawing.ImageAnimator.ImageInfo.UpdateFrame()
at System.Drawing.ImageAnimator.UpdateFrames()
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
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.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at ANAX_Dashboard.AnaxDashFrm.Callme() in E:\ANAX Dashboard working folder\ANAX Desktop Reports\ANAX Desktop Reports\FrmAnaxDashboard.cs:line 94
Category: Error
|
|
|
|
|
Reply to what? You didn't put in a question.
|
|
|
|
|
|
|
I am working in vb.net with c# - 2008
Hear Some Problem to fill Combobox using recursion in Duplication Problem in my combobox please help me
my table and coding like this
In table using Self join
*************** Table******************
Id Parent_Id Name
1 Null Sales
2 1 Item1
3 1 Item2
4 2 Item3
5 3 Item4
6 4 Item5
7 Null Purchase
8 7 Item1
9 7 Item1
My table data are look like that
1) in my application i want to fill only the Sales and that's child to releted with them in combobox
2) in my application i use to recursion that's work but that show many time the purticulr some items
3) if any budy have the solution of my problem please help me and if possible to give me code releted with otherwise give some example releted with it
please
|
|
|
|
|
So the data is duplicating in the combobox? Could you post the code you have currently. Without it, it's quite hard to say where the problem lies.
|
|
|
|
|
1)
public void FillCombo()
{
DataTable dt = new DataTable();
StrSql = "select Level_Id,Level_Name from UserLevel";
StrSql += " where Level_Id = '2'";
dt = qry.FillDataSet(StrSql).Tables[0];
if (dt.Rows.Count > 0)
{
if (ChildExistOrNotInCombo(2) == true)
{
AddChildCombo(2, ref dt);
}
}
this.cmbParentLevel.DataSource = dt;
this.cmbParentLevel.DisplayMember = "Level_Name";
this.cmbParentLevel.ValueMember = "Level_Id";
}
2)
private void AddChildCombo(int objid,ref DataTable Table)
{
DataTable Objdt = new DataTable();
int Objval = 0;
StrSql = "select Level_Id,Level_Name from UserLevel";
StrSql += " where Parent_LevelId = " + objid + "";
Objdt = qry.FillDataSet(StrSql).Tables[0];
if (Objdt.Rows.Count > 0)
{
for ( int i = 0; i <= Objdt.Rows.Count - 1; i++)
{
Table.ImportRow(Objdt.Rows[i]);
Objval = Convert.ToInt32(Objdt.Rows[i].ItemArray[0]);
if (ChildExistOrNotInCombo(Objval) == true)
{
AddChildCombo(Objval, ref Objdt);
}
}
}
}
3)
private bool ChildExistOrNotInCombo(int ObjParentId)
{
StrSql = "select * from userlevel where Parent_LevelId =
" + ObjParentId + "";
if (qry.CheckExist(StrSql) == true)
{
return true;
}
else
{
return false;
}
}
in my database this item has only 12 record but in this that retrun the 77 record in some are wrong but i dont't know please help me on this problem as soon as possible
|
|
|
|
|
The first thing is that why are you checking from database if item exists in combo in ChildExistOrNotInCombo? Shouldn't you be checking if the datatable you're filling contains the item?
Also it seems that you check from database if the row has children? I think it's unnecessary since you could simply call recursion. If there are no children, nothing's added.
You don't check how many rows your query returns in FillCombo. You use it like it returns 1, but if it returns several rows, I think you'll have extra data in the datatable.
And when you do the recursion, you select based on the row level_ID, is this correct? Shouldn't you select using Parent_ID like Parent_ID = ID (based on the data you posted in the first post)? So is Level_id same as ID in the first post and Parent_LevelId is the same as Parent_Id in the first post.
So basically it could be something like:
public void FillCombo()
{
DataTable dt = new DataTable();
StrSql = "select Level_Id,Level_Name from UserLevel";
StrSql += " where Level_Id = '2'";
dt = qry.FillDataSet(StrSql).Tables[0];
if (dt.Rows.Count > 0)
{
MessageBox.Show("More than one row");
}
AddChildCombo(2, ref dt);
this.cmbParentLevel.DataSource = dt;
this.cmbParentLevel.DisplayMember = "Level_Name";
this.cmbParentLevel.ValueMember = "Level_Id";
}
private void AddChildCombo(int objid,ref DataTable Table)
{
DataTable Objdt;
int Objval;
StrSql = "select Level_Id,Level_Name from UserLevel";
StrSql += " where Parent_LevelId = " + objid + "";
Objdt = qry.FillDataSet(StrSql).Tables[0];
for ( int i = 0; i <= Objdt.Rows.Count - 1; i++)
{
Table.ImportRow(Objdt.Rows[i]);
Objval = Convert.ToInt32(Objdt.Rows[i].ItemArray[0]);
AddChildCombo(Objval, ref Objdt);
}
}
|
|
|
|
|
1) But sir in my database there is no extra data my database data is show below
Hear is my Database
2 NULL Account
3 2 Perment
4 2 Tempray
11 NULL Sales
12 11 tttttt
13 11 pppp
14 12 qqqqq
15 13 jjjjj
16 15 asd
17 16 sasda
20 17 fffff
23 NULL Purchase
28 23 Pur1
30 20 qqqqqqq
31 14 aaaa
32 15 bbbbbbbb
33 32 iiiiiii
34 3 Company Employees
35 4 Contract Base Employee
2) i am trying as u say but that's are return the same thing as they return early
3) in my application i want to just add Parent data with the all child in my combobox if there are any other way to fill the combobox so please tell me
4) Example : The Sales is Parent Node and the that releted all child are fill in to the combobox with the Parnet Node
5) Hear the NULL is define that that is Parent Node.
|
|
|
|
|
I didn't say that the problem is in the data in the database, but how you use it.
One problem is that I don't know what your method qry.FillDataSet does. Perhaps it adds rows to an existing datatable? In that case you would have too much data.
Lets make it a bit simpler (I corrected few typos I made earlier):
Data
Level_Id ParentId Level_Name
-----------------------------
2 NULL Account
3 2 Perment
4 2 Tempray
11 NULL Sales
12 11 tttttt
13 11 pppp
14 12 qqqqq
15 13 jjjjj
16 15 asd
17 16 sasda
20 17 fffff
23 NULL Purchase
28 23 Pur1
30 20 qqqqqqq
31 14 aaaa
32 15 bbbbbbbb
33 32 iiiiiii
34 3 Company Employees
35 4 Contract Base Employee
public void FillCombo()
{
DataTable dt = new DataTable();
string sql = "select Level_Id, Level_Name from UserLevel"
+ " where Level_Name = 'Sales'";
dt = qry.FillDataSet(sql).Tables[0];
if (dt.Rows.Count > 1)
{
MessageBox.Show("Problem: More than one row");
}
AddChildCombo((int)dt.Rows[0]["Level_Id"], ref dt);
this.cmbParentLevel.DataSource = dt;
this.cmbParentLevel.DisplayMember = "Level_Name";
this.cmbParentLevel.ValueMember = "Level_Id";
}
private void AddChildCombo(int parentLevelId,ref DataTable Table)
{
DataTable childTable;
string sql = "select Level_Id,Level_Name from UserLevel"
+ " where Parent_LevelId = " + parentLevelId + "";
childTable = qry.FillDataSet(sql).Tables[0];
<code>-- Check with debugger that rows are correctly</code>
for ( int i = 0; i <= childTable.Rows.Count - 1; i++)
{
Table.ImportRow(childTable.Rows[i]);
AddChildCombo((int)childTable.Rows[i]["Level_Id"], ref Table);
}
}
Now use the debugger to see if row amounts and the data is correct in the FillCombo and also in the recursion.
|
|
|
|
|
Qry is a obj of my class
FillDataSet is one Common Function that's only fill the dataset or datatabel
In That the Data Will come is proper but Sir that Are Duplicate in to the combobox
Just Example the
1) 'qqqqq' That's are show in combo ManyTime that's way the some other data are also come the many times
Hear Sir Any Other Way to Fill the Combo
My one Friend Sid that that's to fillcombo with use Recursion is not give Proper Result and also say that that it is not proper way.
So if U know to the Other Way to Fill Combo so Please Tell Me That's Request Please
|
|
|
|
|
aajignesh wrote: In That the Data Will come is proper but Sir that Are Duplicate in to the combobox
Maybe a dumb question, but do you clear the combobox at any time? If not, you should add Clear to the FillCombo. Also you you may want to clear bindings. Like:
public void FillCombo()
{
<code>this.cmbParentLevel.DataSource = null;</code>
DataTable dt;
strinf sql = "select Level_Id, Level_Name from UserLevel"
+ " where Level_Name = 'Sales'";
dt = qry.FillDataSet(sql).Tables[0];
if (dt.Rows.Count > 1)
{
MessageBox.Show("Problem: More than one row");
}
AddChildCombo((int)dt.Rows[0]["Level_Id"], ref dt);
<code>this.cmbParentLevel.Items.Clear(); </code>
this.cmbParentLevel.DataSource = dt;
this.cmbParentLevel.DisplayMember = "Level_Name";
this.cmbParentLevel.ValueMember = "Level_Id";
}
aajignesh wrote: My one Friend Sid that that's to fillcombo with use Recursion is not give Proper Result and also say that that it is not proper way.
Recursion is just a technique to handle data which is in tree format. It can be used for many situations, like filling a combo. There's no reason why filling a combo with a recursion wouldn't work. The problem is in the implementation.
aajignesh wrote: So if U know to the Other Way to Fill Combo so Please Tell Me That's Request Please
This depends where the data is coming from. Are you querying for example SQL Server database?
|
|
|
|