|
Thank You Very Much!! It helped. Works perfectly! Thanks again...
|
|
|
|
|
Oh I see, you're using .NET 2.0 where Control.ControlCollection has been modified compared to 1.1/1.0.
But nevertheless, although it's easily possible to access another Form's controls directly (for example by making them public or exposing a public property for them), it's better style (and easier to maintain/modify) if you don't rely on a certain control to display your data but let the other Form handle it.
So instead of writing something like
frm1.comboBox1.DataSource = new string[] {"aaa", "bbb"}; (given that comboBox1 is visible, of course) I'd suggest NOT exposing comboBox1 but instead adding a property to transfer the strings to display, for example similar to this:
...somewhere in Form1...
protected string[] _choices;
public string[] Choices
{
get { return _choices; }
set
{
_choices = value;
comboBox1.DataSource = value;
}
} and then in your test write:
frm1.Choices = new string[] { "aaa", "bbb" }; That way you've separated your data from the presentation of this data and can easily change the comboBox to a different control for showing your strings without breaking compatibility with your callers.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Thanks for answer, I think its better way too.
I dont know why, but by me that dont works...
I do so:
class Form1
{
private comboBox comboBox1;
protected string _choices;
public string[] Choices
{
get { return _choices; }
set
{
_choices = value;
comboBox1.DataSource = value;
}
}
public void someFunctionInForm1
{
Class1 cls1 = new Class1();
cls1.test();
}
}
class Class1
{
public void test()
{
Form1 frm1 = new Form1();
frm1.Choices = new string {"aaa", "bbb"};
}
}
If I make the same from Form1 class:
...somewhere in Form1
Choices = new string[] {"ccc", "ddd"};
all works, but when I do this in Class1 (like above) - dont work.
|
|
|
|
|
You're doing it again. In your test() method you still have this:
public void test()
{
Form1 frm1 = new Form1();
frm1.Choices = new string {"aaa", "bbb"};
} Remove the first line, as it is creating a new instance of Form1 , and refer to the instance that you've stored locally from the constructor call (called _frm1 i think?).
Cheers,
Will H
|
|
|
|
|
Thanks, I've thinked after creating properties I can access it so
but then I dont understand what is the advantage of using properties to access controls? Because in this case its look like the same, but through property.
|
|
|
|
|
|
Thanks. Very good article.
|
|
|
|
|
hi,
i'm a beginner in c# & SQL server 2000, and i did a project with them but i need to make an .exe file that don't force the user to have sql or any thing else.
just to run the exe and he can use the project.
thanx
|
|
|
|
|
If you want to embed the database in your setup program then SQL Server isn't going to work for you. As the name suggests it is a server product. There is MSDE which can be distributed with your application but I think it is still a separate install.
You might want to consider something more along the lines of Vista DB[^]
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
|
emran834 wrote: Is that you meant My application will be running stand alone in the user's computer or The user must have SQL server installed !!
The latter, SQL Server must be installed.
emran834 wrote: Whenever i build my solution, the RELEASE Folder is Stand Alone and My .mdf file is inside the RELEASE Folder which made sense to me that it will run stand alone. Ain't I right ?
No, that isn't right. The database file is useless without SQL Server to open it and server data from it and allow changes to it. In your application you never access the file directly. SQL Server is the only thing that accesses the file. Your application accesses SQL Server not the file.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
i don't think that user must have SQL in his PC.
i need a way to let the project stand alone without SQL
am i obvious !!!?
thanx
|
|
|
|
|
moonangel_bio wrote: i don't think that user must have SQL in his PC.
Why do you think that?
If you are deploying SQL Server files to a PC then you musr have SQL Server installed on that PC in order to use the files. You cannot have SQL Server running on another PC accessing its files across the network. The files MUST be local to the installation of SQL Server.
moonangel_bio wrote: i need a way to let the project stand alone without SQL
Then don't use SQL Server.
moonangel_bio wrote: am i obvious !!!?
That doesn't make sense.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
No matter what you use, you can't embed the database in the .EXE. A running .EXE cannot be modified. At the very least, you'll need the .EXE and a database file. To get a working database that doesn't need a server, you'll have to use a file-based DB like Access (Yuk!).
Your SQL Server implementation is useless without an installed SQL Server that the customer can use.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
O my god ! I am developing my Application with SQL Database, thinking that it will be stand alone distributable. Now If I change my Datbase to OLEDB ( Microsoft Access ) ? then will it be stand alone ? I read your previous posting where you said that if I use Access then it will be ok. I am thinking If I just change the database file and Connection String, will be all code be working ? And I hope the SAME SQL will will be working just Parameters sign ( @ or ? )is different, right ?
-- modified at 16:35 Sunday 5th February, 2006
|
|
|
|
|
I don't know much about Access. It used to be (and this is getting on for 10 years ago) that you'd need some additional files installed to use the Access database through ODBC, but I really don't know about .NET. It may be possible.
The SQL is similar but there are differences. You've already spotted the parameter one. Access doesn't support Stored Procedures, so if you have any of them they will have to be re-written.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi colin,
thanks for your time.
yes, ADO .NET supports Access and C# Express can help me to use the Access same as SQL. But I have done some research on google and Realized that, If I started with Access, that was a different story, but at the middle of this time of my application development, it will be very hard to go through all Conversion. I was thinking how can i manage SQL database to make Stand Alone. One thing I can do, I can put the SQL Express executable in my installer file so that whenver user install my software, my installer will install SQL server from CD. Or I can learn about MSDE, I got a nice article about MSDE from Code Project, http://www.codeproject.com/cs/database/msdeinstaller.asp[^]
Can you tell me which one is efficient solution !!
Regards,
Emran
|
|
|
|
|
Hi,
I have checked the link VISTA DB that you provided in the last posting. Excellent Solution exactly what I wanted. thanks for the information. Have you used that ?
|
|
|
|
|
I'vw played with it a little, but I've not found a project that I'd use it on - I work mostly with large enterprise applications where the database is arround a Terrabyte in size.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hello.
I am writing a new component that has a property that gets an Enum type.
I want the designer of the project, that is using my component, to show that property in the Visual Studio Propery Viewer with a drop down property that lets the user select from a list of Enums that are decleared in his project.
How can I do such a thing ? (in C# 2003)
How do I control the Property view of my control ?
Thanks.
|
|
|
|
|
|
hello
how can i making sound & video transfert in my c# or VB.NET application
11111111111111111111111111111
|
|
|
|
|
I have an application that needs to save settings while exiting. In which eveny should i write the code for saving the settings. Does the Form.Closing event tigger when the form was in focus and the user closed it? The UI of my application may not be visible because it runs in the system tray and it is closed from a system tray icon context menu.
|
|
|
|
|
You can also handle the application's ThreadExit or ApplicationExit event. This may be a more robust way of saving your application's settings - I believe (but am not certain) that these events are fired even if the app is forcibly shutdown via the task manager.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
hello folks.
if my user is behind a firewall that only allows connection through port 80 how can i make my application get binary data and respond to the outside world also in binary data through port 80 . How can my application distinguish the binary content coming from http request from internet explorer (suppose the user is currently browsing the internet and opening my client application). How can i distinguish between the data comes from my server and the data comes from any webserver during browsing through port 80.
Thanks Everybody.
Human Knowledge belongs to the world
|
|
|
|