|
Hi
I create a Glob class ( Global is a keyword ), then create public static properties for global variables.
internal class Glob
{
private Glob() { }
private static Prog _Prog = null;
public static Prog Prog { get { return _Prog; } set { _Prog = value; } }
}
Some people say that global variables are a bad thing, but like any construct, they are sometimes useful
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
|
hey guys I have two questions ( sorry if they are stupid ones ...)
1- I have two forms in one i declare a variable
public int number;
Then i assign a number to it and i want to use it in my second forms
firstform ff = new firstform();<br />
messagebox.show(ff.number.tostring());
I don't get the correct number ?!
2- I have a Combo Box, the list comes from a table called StateDB
State_cb.DataSource = StateDS.Tables["StateDB"];<br />
State_cb.DisplayMember = "StateName";
and it works but i also want to bind it with another table meaning that in my second table called University i have a list of people that are from diffrent universities when my form is loaded I want to have the correct state for that person already selected but it doeasn't work out that way.
State_cb.DataBindings.Add("SelectedItem", myDS.Tables["UniversityDB"], "UniState", true);
Is it possible to do so ??!!
sorry it got so long
Tnaks
-- modified at 2:51 Saturday 1st April, 2006
|
|
|
|
|
mrkeivan wrote:
I don't get the correct number ?!
What do you mean by this?
I'm taking a guess in the dark here but:
You've already got a form which contains a number and you want to get that number from it. The statement:
mrkeivan wrote: firstform ff = new firstform();
will create a new instance of the class and have a "new copy" of the variable. If you want to access the other instance of the form then you'll have to create a property or field that's accesible to both routines so that you are getting it from the correct instance.
Ed
|
|
|
|
|
ok let me light you up , I have to forms, in form one I have a variable called Number
public int User;
in the process this variable recieves a number.
In the second form I need this number for another process, but all i get is either Zero or nothing.
how about the second problem about the combo box can you help me out with that one too ?
Thanx alot
Mr.K
|
|
|
|
|
I still think that it's because you're creating two instances of the form, i.e. you're retrieving the number from a new copy of the form. (Based on your new firstform statment).
mrkeivan wrote: Zero or nothing.
Eh? For an int zero is nothing
mrkeivan wrote: how about the second problem about the combo box can you help me out with that one too ?
I don't do that much databinding so can't think of the top of my head and don't have the time to mess around trying things out. Sorry.
Ed
|
|
|
|
|
I also think the same, that the problem goes back to creating two instances of the form, so how can i do that, is there any way i can call that form with out creating an instant of it ?
I was thinking about creating a class to hold the data but again i gotta creat a new instant of that clas:(s !?!
|
|
|
|
|
mrkeivan wrote: I also think the same, that the problem goes back to creating two instances of the form
Why didn't you say you were creating two instance of the form, it's a guarantee that this is the problem
mrkeivan wrote: is there any way i can call that form with out creating an instant of it
Yes, multiple ways, the easiest would be in the form which creates the secondary form, create a public field / property which is accessible to all the method ("processes") which you require. They can then reference the form through them.
Ed
|
|
|
|
|
Thanks man, thats was very helpful
Mr.K
|
|
|
|
|
Hi all,
Could any one tell or send me the differences between HTML and XML :->
Thanks alot
Hamody
|
|
|
|
|
|
HTML is used to make web pages.
XML is used to handle data.
---
b { font-weight: normal; }
|
|
|
|
|
In the project I am working on ,I need to add new records in a database and show the first column of all these existing records in a dropdownlist on the same page.The problem is that when I add a new record its value doesn't get reflected in the dropdownlist and I need to refresh the page to see the changes.What should I do so that I will not need to refresh the page and still the value will get added to dropdownlist.
Thank you.
|
|
|
|
|
if you dropdownlist is called for example dropDownList1.
dropDownList1.DataBind();
|
|
|
|
|
I have already done it ,my code on page load is
query = "select * from CashDataTable";
conn = new OleDbConnection("FILE NAME=C:\\abc.udl");
conn.Open();
cmd = new OleDbCommand(query,conn);
reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "AcctNumber";
DropDownList1.DataValueField = "AcctNumber";
DropDownList1.DataBind();
conn.Close();
but still it doesn't work.
|
|
|
|
|
you are doing that on Page_Load, that only runs when the page loads, that's why it updates when you refresh the page,
if you want to force it to update you need to call DataBind again.
I don't know how you are updating the database, You might need to set the autopostback of controls that update the database to true. In that case you won't need a separate call to the DataBind method because it's executed at the database level, however, it also depends on what you are doing the the dropdownlist, if you want to keep the selection the user makes you need to check the IsPostBack property and not bind the control every time the page loads,again, not knowing more is difficult to say how to do it.
|
|
|
|
|
Hi there,
I'm looking for a free dockable panel (VS 2003/2005 like) for using in my C# windows application.
Can you help me?
Thank you in advance.
-- modified at 0:32 Saturday 1st April, 2006
|
|
|
|
|
You might want to take a look at WeifenLuo.WinFormsUI.Docking, I don't know if there's a homepage for it but it's integrated in SharpDevelop and you can get the source and compiled binaries from the SharpDevelop downloads
Ed
|
|
|
|
|
Hi,
I have two seperate c# projects both working fine. I can see that .NET allows multiple projects in a single solution. Question is how do I run the other project from the default solution project at runtime (I am rather new to .NET)
Thanks.
BIK
|
|
|
|
|
that depends on what you want to achieve.
Usually, you will place more than one project in the same solution if they are related (not necessarily means they will run together), but many times, if you are developpig a multitier application, you will have for example your main project, which will generate an .exe (windows or console application) and some class libraries that will generate a .dll, you can run code from those class libraries by adding a reference to them to your main project (the .exe) and then, you can create instance of the classes, call methods, set properties. etc.
|
|
|
|
|
I am trying to write an application that opens a telnet session and sends commands to device.
Any help will be grealy appreciated
|
|
|
|
|
|
I am writing a C# windows program
There is a very strange problem about C# comboBox Control
That is the combobox control's edit control can not deal with mouse operation itself,nor can it deal with the standard operations the edit control can do,such as cut paste copy(actually it does not have the context menu like edit control),Why is that,Is it because I do not make some right property settings in combobox control or this control actually can not deal with that ,I should do it in my own codes,Please Help
Great Thanks
-- modified at 21:04 Friday 31st March, 2006
|
|
|
|
|
the ComboBox has its own set of properties that can be assigned values just as any other control. If you select the control and have the properties windows open (if not go to view --> properties) you should see all the public properties of the control (usually the properties window displays on the bottom right side of the ide's window, unless you have configured visual studio to use floating and not docked windows).
|
|
|
|
|
Thanks For Help
I know I can set these properties,but I want to know how to set the properties to meet my requirements
to let the combobox control's edit control part work like odinary edit control
|
|
|
|