.NET Windows Forms >> Q:) Need sample code for a best practices Windows Form app

by news.microsoft.com » Tue, 24 Feb 2004 22:08:42 GMT

Is there anything like Petshop or Duwamish but more of a regular
client/server windows forms based app that demonstrates good Window Forms
coding practices? Or something that just demonstrates the right way to
bind controls to data for a c/s app?

My .Net experience is mostly web app based so I'm used to opening datasets
and going back to refetch records on subsequent server roundtrips, etc.

I'm not sure about the best way to work with data sets and bound controls on
a client/server type of app where I can be fully coupled to the database.
I used to work with Delphi which had components for persistent database
connections and table objects that you opened once, wired your grids and
edit boxes up to, and did all of your updates through. I know .net can do
that but everything seems oriented towards disconnected apps. Then again,
maybe thats the better way, either way - some pointers would be helpful...

Thanks

bill
wiw at nyc . rr com





.NET Windows Forms >> RE: Q:) Need sample code for a best practices Windows Form app

by andmort » Tue, 24 Feb 2004 23:56:50 GMT


You might find this PAG helpfull, should be a few more up there which are
pertinent

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/
eappint.asp

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm "

.NET Windows Forms >> Q:) Need sample code for a best practices Windows Form app

by bill » Wed, 25 Feb 2004 00:07:05 GMT

Thanks. I'm looking that over but it's more high level than what I need at
first.

I'm looking more for some nuts and bolts in terms of where to define
datasets & record sets so they're available to any event on the form as
opposed to creating them and fetching records for each event the way a web
app might.

Basically a regular form where you view records and can add/edit/delete but
done the right way including traps for optimistic lock failures, etc.




http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/
rights.

Similar Threads

1. Best Codeplex sample for showing best coding practices? - Asp.Net

2. Best practice needed to marshal STL data from managed code to unmanaged code & vice versa

Problem
Best practice needed to marshal STL data from managed code to unmanaged code & vice vers

Details
managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a mixed mode DLL
unmanaged code is written in unmanaged C++ & resides in an unmanaged DL
Product used is VS.NET 200

Please tell me what is the best practice for getting and setting data fro
unmanaged to managed part when I have a class with references to STL objects as member
function parameters
For instance if I have the following class in an unmanaged Dll

class UNMAN1_API CUnman1

public
	int GetStdString(std::string & strText)
	int GetStdVector(std::vector<std::string>& vectText)

	int SetStdString(const std::string & strText_p)
	int SetStdVector(const std::vector<std::string>& vectText)
}

I can create the class in a managed C++ mixed mode Dll without problems. I searched the Web (Internet) and have found a solution for setting the standard string, whic
looks like follows

int Form2::TestSTL2(void

	CUnman1 cUnman1
	std::string stdstrText

	String *pStrTmp = S"This is a string with more than 15 characters.\r\n"
	IntPtr intPtr = Marshal::StringToHGlobalAnsi(pStrTmp);
	char *pcTmp = static_cast<char*>(intPtr.ToPointer());

	stdstrText = pcTmp

	cUnman1.SetStdString(stdstrText)
	Marshal::FreeHGlobal(intPtr)

	return 0


But it looks strange because when you assign the unmanaged allocated character array to the standar
string, should there not be a new allocation in the standard string class?. Is this kind of processing correct

For the other three function
- int GetStdVector(std::vector<std::string>& vectText)
- int GetStdString(std::string & strText)
- int SetStdVector(const std::vector<std::string>& vectText)
I have not found anything, neither in MSDN nor on the Web

Is there a generic approach how to pass STL objects between both worlds in the mixed mode DLL

Any help / hints would be apreciated

Regards & thanks in advanc
	Johannes Unfrie

---------------------------------------------------------------------------
D.I. Johannes Unfrie
Senior Engineer SpeechMagi
Philips Speech Processing
Speech Recognition System
Triesterstrasse 64, P.O. Box 217, A-1101 Vienna, Austri
Tel. +43 1 60101 280
Fax +43 1 60101 414
mail:  XXXX@XXXXX.COM 
web: www.speechrecognition.philips.co



3. What is best practice for storing SQL code for an app - VB.Net

4. Best practice for coding two similar forms?

Hi, I am a C/C++/C# programmer that has inherited a HUGE VB.Net
application with several VB forms.  I am a mediocre VB programmer.
Two separate companies are now going to be using the application.
Most of the forms are fine for both companies.  A few of the forms
require significant modification for one company to use the.  Of the
forms that I do need to modify about 75% of the VB.Net code behind the
new form and the old form will be the same.

If I was coding this in C#/C++ I'd handle it this way.

Create and #include file with the common code for both forms.  We'll
call this form1_common_code.inc.
Create a separate source file for each form with the code that was
unique to that form.  We'll call these form1_a.vb and form1_b.vb.
I would then have form1_a.vb and form1_b.vb include
form1_common_code.inc.
>
>From what I've been able to find in the VB documentation VB does not
support this approach.  The recommended approach seems to be to create
a custom control with the common code and have each form and have each
form use the custom control.  I do not think that a custom control
will work here.  The nature of changes that I will need to make just
do not fit that approach.  I'm trying to avoid created a completely
separate form for each company, but that does seem to be the simplest
approach in the short run, with obvious problems in the long run.

Does anybody have any advice on a good approach to this before I
commit myself to maintaining completely separate copies of the form
for each company?

Thanks,
John

5. Windows Forms semi-connected data-access best practice - ADO.Net

6. Best practice for windows form and database access.

   I am doing a project where we need to read a write data to a
database (SQL Server 2K in this case). I have seen the use of data
binding to link a property of a control to a field in a record set from
a database. It seems like this can give some benefit like being able to
easily ignore all changes and not change the current data, to push and
pull data from the database, etc... However, I'm wandering if this is
the best way to really do professional apps. It seems like this method
forces some pretty generic navigation between records. I'm concerned
about the methods of testing validity of data - especially between
multiple fields. I have not developed database applications in .NET and
barely any in VB6. My primary usage for storing and retrieving data was
from when I used to program a lot in BASIC, PASCAL, C, and so forth
where I was doing direct file access and effectively managed my own
database system per application I wrote. I had complete control over
when, how, where, and whether to store the data. I guess I'm trying to
figure out if a hybrid between these two methods is the more
appropriate - professional way, or if binding the controls to data sets
is really the best way now. Any advice is welcome - the more the
better.
   Thanks in advance!

7. Windows Form App Within Another Windows Form App - CSharp/C#

8. Looking for good windows forms sample in C# showing how to work with ListBox

Hello,

This seems like it should be easy...

I have a listbox on a .NET form.

I add a new item to the list box.

How can I associated a separate data value?

Can I add (and retrieve) an arbitrary data value independent of the text
displayed?

I also tried creating an object and providing a ToString override.  That did
let me add the item but I still didn't see a way to lookup based on
enumerating the list...

Thanks,
-- 
Grant Schenck