|
Thats a great question!.
The dafault behaviour is windows forms creates at least one currency manager object for each data sources included in the form. The currency manager is managed through BindingContext object.
This behaviour is intentionally incorporated in order to keep all the controls on the form synchronized with data source.
For Instance if you have two combo boxes FirstName and LastName bound to dsCustomer, then if user changes FirstName, the lastname column also changes in order to reflect the correct customer. Windows forms moves binding context beind the scenes and programmer is relived of writing code to synchronize the controls.
If you do not want this feature, then you need to make a copy of the datasource and then bind it to combo boxes as illustrated in the code below.
private void Form1_Load(object sender, System.EventArgs e)
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("Select top 10 * from authors", "Data Source=ITD2142s;Initial Catalog=pubs;Integrated Security=SSPI;");
ds = new System.Data.DataSet();
da.Fill(ds);
comboBox1.DataSource = ds.Copy().Tables[0] ;
comboBox1.DisplayMember = "au_lname";
comboBox2.DataSource = ds.Copy().Tables[0] ;;
comboBox2.DisplayMember = "au_fname";
}
Hope this helps .
Cheers
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Thanks a lor Ravinda ,
I used .Clone() function but it didnt work..
Well at least I should have given one more try
I have a one more question , Is this copied dataTable will be stored logically or physically in memory ?
Thanks in advance..
Bahadir Cambel
|
|
|
|
|
Clone function will only copy the structure not the data.
Copy function will copy both structire as well as data.
Hence Copy function is more relevant in this case.
The copied data will be stored physically in memory.
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Thanks again for great help...
Bahadir Cambel
|
|
|
|
|
hi
i am working in a windows form in C#. i have a datagrid which displays values from the table in the database. i know how to assign custom headers or rather to change the column names. now suppose i change the ordering of the columns, how will can i set the column names respectively without keeping a track of their order.
for eg.
if my datagrid is such
table name:software master
softwareid softwaredesc remarks
and i have given column names for them in the datagrid keeping their order into consideration as
code description remarks
now if the secondcolumn is to be shown as the third column,how can i change it so that even the custom column names are rearranged accordingly.
plss help
i have to create a common method which is to be called by more than form. in that case the columns of the grid are changing always.
regards
sukanya
|
|
|
|
|
One way is to use aliases for columns in SQL query itself.
e.g. the query can be
SELECT Softwareid as Code, softwaredesc as description, remarks as remarks
FROM SoftwareMaster
Cheers
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
I have a problem building a Solution. The solution contains 2 projects. Project1 is a DLL that supplies some business logic. Project2 is the Winforms Wizard. I have set the Project2 to be dependent on Project1 to build. Whenever I build the solution I get the following error:
------
The file 'Project1.dll' cannot be copied to the run directory. The process cannot access the file because it is being used by another process.
------
I am being driven slowly insane by this one. Please let me know if there is anything that I can do to handle this problem without having to shut down the IDE and destroy the obj directory for Project1.
Thanks in advance for your time and help
Ward
Frag
Try, Fail..Fail, Succeed
Tool Developer
Michigan, USA
|
|
|
|
|
I dont know the exact origin but whenever I have this error (very rarely) I switch the CopyLocal property of the reference to false. This way it doesnt copy the dll and thus doesnt have any conflicts
|
|
|
|
|
You need to remove the reference to Project 1 from Project 2 whenever you get this error.
Then build Project1. restablish the reference and then build all.
This should resolve the error.
Cheers
Ravindra Sadaphule
MCSD.NET
|
|
|
|
|
Ravindra,
Thanks for the note. I tried that and it worked. I wonder if the condition will evolve again over time? What is the cause of this problem? Is this something that will be fixed in the IDE?
Ward
Frag
Try, Fail..Fail, Succeed
Tool Developer
Michigan, USA
|
|
|
|
|
I use the Process.GetProcessesByName-Method to retreive all processes, having the same name. In certain circumstances this processes run under different users. How can I find out which user runs which process?
Completely different methods than using System.Diagnostics.Process are also appreciated.
Thanks.
|
|
|
|
|
You can get this info by using the System.Management namespace functions. I do not have an example in c#, but I have one in vb.net if you are interested.
Basically:
System.Management.ConnectionOptions con = new System.Management.ConnectionOptions;
System.Management.ManagementScope mgmtScope = new System.Management.ManagementScope("\\localhost", con);
System.Management.ObjectQuery objQuery = new System.Management.WqlObjectQuery("SELECT * FROM win32_process");
System.Management.ManagementObjectSearcher objSearch = new Management.ManagementObjectSearcher(mgmtScope, objQuery);
System.Management.ManagementObjectCollection objCol = objSearch.Get;
Object obj;
//Loop through all the processes in objCol to find the one you want.
foreach(System.Management.Object objProc in objCol)
{
//if the obj is the proc you are after
obj = objProc.InvokeMethod("GetOwner",info); //where info is an array look at docs
//I think info[0] is domain and info[1] is user
}
This example code was cobbled together in the message reply editor, and I do not use c# enough to say that these are valid statements, but if you read the documentation on the System.Management objects used, you should be able to figure it out.
Scott Serl
|
|
|
|
|
Hi all,
I new a solution file and then added 2 new projects in there. the project were
1) Smart Device Application
2) ASp.Net web service
I added a sample string helloworld() web service to 2) and then I added a form with a text box and a button to 1).
When the mobile simulator (default pocket pc) on .net is running, pressing the button on the form will call the web
service 2) helloworld and helloworld returned things will display on the text box of the form.
I hv also added 2) as 1)'s web reference.
the solution compiled and deployed successfully. But when I press the button to call the web service, an error
message has been displayed, telling project 1) cannot find web services of project.
Any idea on this problem?
thanks much.
Rene Xavier
|
|
|
|
|
Hi,
Using localhost can cause this type of problem. If you are using the localhost in the URL use your machine name instead of localhost in the URL.
Thanks and Regards
SGS
|
|
|
|
|
Hi,
I got your point, it seemed the client can found webSrvProj now. But when I access statement 2 as below:
webSrvProj.webSrv webSrv = new abc.webSrvProj.webSrv();
this.textBox1.Text = webSrv.CallExternalWebService(); // this web service just write a "hello world"
exception still raised
System.Net.WebException
Additional information: The remote service returned an error: (401) Unauthorized
Any idea ? Who grant right to who? And how to grant rights? As I remembered that I hv grant all IIS access priviledges on both mobile client application and the web service application.
Thanks in advance!!!
Rene Xavier
|
|
|
|
|
Hi,
I dont have an exact solution for this. But are you able to aceess your webservice from a remote machine. Please check that.
Thnaks
SGS.
|
|
|
|
|
Hi,
Yes, other machine can access the webservices from the hosting machine.
Thanks much,
Rene Xavier
|
|
|
|
|
Hi all,
I have a set of thumbnails stored in a database with info such as date created, date added, created by who, size etc.
I want to be able to display the thumbnails according to selection, ie user and/or date.
I'd like to be able to display the images in a datagrid on a Windows form but have no clue how to do it.
Is it possible?
Thanks
S.
|
|
|
|
|
I have created an MDI form that contains a main menu with File -> New and Exit and another Top menu Window ->Cascade, Horizontal cascade and vertical cascade
I also added the Context menu and made it as a popup menu which is not getting displayed at runtime
Please help me
|
|
|
|
|
hi,
if u have already set the property of the context menu in the form's properties to the name of the menu.... but still it is not appearing
then u have to give this code
<contextmenuname>.mdiParent=this
check out and this may work out....
regards
sukanya
|
|
|
|
|
Thanks for your reply
but i have already set it to parent but still when it dint worked i posted it in the forum
arnold
|
|
|
|
|
Hello guys.
I need some help on organization our project strategy.
1. What we need?
1.1. First of all we need a "module", that would handle most part of project logic and functionality. Let's keep call it "module" untill we can't find a phisical instance name for it.
Requirements:
- Single instance per computer
- Possibility to work all the time
- No need to have graphical interface
- Possibility to communicate with and be controlled by some GUI application
1.2. At second we need a GUI application that would communicate and control the "module". There are no special requirements for this application and it's clear how to create it. So that's not a point of interest.
2. What are the questions?
2.1. What kind of programm the "module" should be???
2.2. Maybe it's better to separate "module" functionality between several programs???
2.3. What kind of intercommunication between GUI app and "module" should we implement???
3. Our suggestions...
3.1. The "module" should be a Windows Service, but
- How to organize intercommunication with GUI app???
- It's not nessesary for "module" to work all the time, but is desired to be possible.
3.2. The "module" should be a SINGLETON COM EXE Server, but
- It could be created using ATL and we have pure documentation on ATL and it's much harder to code with ATL than with C#.
3.3. The "module" should be a kind of demon application, supporting some kind of IPC, but
- How to create windowless demon application???
- How to organize IPC???
3.4. The "module" should be a simple DLL, but implemented as SINGLETON (one instance per computer), but
- How to make DLL SINGLETON???
As a partner addition, 3.2, 3.3 and 3.4 could have a real Window Service as a starter and handler of "module" vitality.
So, if somebody could suggest any way (better the optimal) of solving the above problems, we'd appreciate it very much.
Thanx for an attention!!!
Vad
|
|
|
|
|
ASP.NET web service will be good for you:
1. It works all the time (without user logon to the machine).
2. Communication with other programs is easy: soap/http.
3. It is a single instance per machine (unless you want to install it multiple times).
4. It has no GUI unless you want to add GUI.
5. It can be implemented in one dll (the default).
6. It can be done in C# or any other .NET supported language.
However, it is NOT a windows service or com server.
Good luck.
My articles and software tools
|
|
|
|
|
i wnat to install Access file in a specified folder of client machine,in setup there is option of storing item in Application folder,how can i make it to install in some other folder? or on root of C drive?
thanks
-adnan
|
|
|
|
|
The best way to do this is making setup and deplyment project and set your project as the start up project of it it will make the whole project setted up and then the user can choose in which place he would setup this application
ByMindOnlyYouCanDoIt
|
|
|
|