|
What is the best way to do this? Implement the content forms as controls, and factor the commonalities out into a host form, or to inherit from a base form. Somehow I think the latter is not as simple as it sounds, but I haven't tried either yet, I'm just checking.
|
|
|
|
|
Hi Brady,
if you need a number of forms all sharing some characteristics or capabilities, it seems
logical to me to define such a specialized form class, then instantiate it (or one of
its derivatives). That is OO for you.
If on the other hand, the commonality is not in the form itself, but rather in the
objects (Controls) it contains, creating one or more UserControls may be the way to go;
in this case, the form isn't anything special, you mainly make it easier to populate it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Well, the forms all share a common layout, toolbar, and menus, so my consdered options are to write a base form with those, inherit, and override some methods use by those, or to write a host form like that for content controls, and expose a generic interface on the controls to react to the interface of the host form.
|
|
|
|
|
Seems it is all about overall aspects such as look-and-feel, and not specific content.
So I would go with the specialized form and derive more forms from it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
hello
i m having a timer event which runs on after 1 minute
in my project i m having the appointment details...so it throws a message that u r having appointment on this time with this person before a particular time(depends on user)..so for this i use a timer event like...
void myTimer_Elapsed(object sender, ElapsedEventArgs e)
{
strCon = strCon.Replace("CONNECTIONSTRING", "Data Source='D:\\Neetu\\Training\\My_Diary_Database.mdb';Provider='Microsoft.Jet.OLEDB.4.0';Jet OLEDB:Database Password='neetu';");
con = new OleDbConnection(strCon);
query = "select alertSetting from settings where ID1=1 ";
cmd = new OleDbCommand(query, con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
setting = Convert.ToInt32(dr["alertSetting"]);
}
con.Close();
dt1 = System.DateTime.Today.AddDays(3);
dt = System.DateTime.Now.AddMinutes(setting);
appointment_reminder(dt, dt1);
}
private void appointment_reminder(DateTime addTime, DateTime Time)
{
int i=0,check = 0;
string appointQuery;
DateTime newdt = addTime, newdt1 = Time;
con = new OleDbConnection(strCon);
DateTime dt = System.DateTime.Now;
string dtToday1 = newdt.ToString("MM/dd/yyyy hh:mm:00 tt");
string dtToday = dt.ToString("MM/dd/yyyy");
appointQuery = @"SELECT * FROM appointment WHERE Apntmnt_date=CDate('" + dtToday + "') and Apntmnt_time = CDate('" + Convert.ToDateTime(dtToday1) + "') order by Apntmnt_time";
cmd = new OleDbCommand(appointQuery, con);
con.Open();
if (con.State.ToString() == "Open")
{
dr = cmd.ExecuteReader();
while (dr.Read())
{
check = 1;
string myTime = dr["Apntmnt_time"].ToString();
strName = dr["Apntmnt_Person"].ToString();
strplace = dr["Apntmnt_Place"].ToString();
i++;
DateTime currentTime1 = Convert.ToDateTime(myTime);
string strTime1 = currentTime1.ToString("hh:mm");
DateTime currentTime = System.DateTime.Now.AddMinutes(setting);
string strTime = currentTime.ToString("hh:mm");
MessageBox.Show("Hello! You Are Having Appointment With " + strName + " At " + strplace + " On Time " + currentTime1);
}
con.Close();
}
}
my problem is this i want to know..m i doing right coz sometimes it gives the error that database connection state is connecting...n some thread problem....so help me...how shud i use this timer event..
|
|
|
|
|
Your errors relate to your ad hoc use of database code, not the use of a timer. Try telling is the exact error messages and what lines create them if you want more specific help.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Try Closing the Datareader
dr.Close();
Develop2Program & Program2Develop
|
|
|
|
|
AOA Dears!
When I parse TextBox1.text into int or Int32 The exception accurs
"Input String is not in correct formate"
How can i resolve this Problem.
Thanks
|
|
|
|
|
Sohail Ahmad wrote: When I parse TextBox1.text into int or Int32 The exception accurs
"Input String is not in correct formate"
How can i resolve this Problem.
Don't type stuff in the text box that isn't an integer.
Seriously, if you expect that the input may not be in the correct format use TryParse instead as it will return a boolean value to indicate if the string could be parsed or not.
Alternatively, catch the exception and handle it. (That much should not have been hard to figure out. Should it?)
|
|
|
|
|
one of the things most Parse() methods don't like is an empty string.
maybe your app is somehow executing your parse code before the box got filled?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I want to get no of Rectengle from user:
Private void Button1_Click(Object sender, MouserEventsArg e)
{
int No_Rect;
No_Rect=int.Parse(Textbox1.text);
for(int i=0;i<no_rect;i++)>
{
e.Graphics.DrawRectanle(............);
}
}
In this Situation
"Input String is not in coorect Format"
Exception Rais. is any other way of parse string to int?
|
|
|
|
|
Hi,
I recommend you try and understand what goes wrong, rather than look for another approach.
There is nothing wrong with the approach, so it must be in the details.
First and forall, look at the symptoms and describe them in full detail when asking this
kind of questions.
Did you check the content of Textbox1.Text? Add some code right where you need it,
and show the value to yourself. Do not assume everything is all-right, since it
clearly is not, otherwise you would not ask for help.
is it a valid number (no more no less)? is it empty? does it contain non-digits?
why don't you use a try-catch block and show the exception.ToString()?
that should tell a lot.
BTW: you should not draw things in a button click handler, anyway e.Graphics will not
be available there.
Seems to me you are a novice in C#, and could benefit a lot from buying and reading
in introductory book on C#.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
|
Neetu Maheshwari wrote: AdminInfo ad = new AdminInfo();
ad.MdiParent = this;
ad.Height = this.Height;
ad.Width = this.Width;
ad.Show();
updateProfileIsUp = true;
Assuming updateProfileIsUp is false , this should work. Everything appears to be good. The only question I have is why are you setting the height and width of the new child form to the same height and width as the parent form?? This would make the chiold form bigger than the MdiClient area of the parent form.
Is this handler being called at all?? Test it. Put a MsgBox line in the code to see if it pops up when you click the menu item. If not, the menu item Click event handler hasn't been wired up, or wired up improperly.
|
|
|
|
|
hi all
i have faced one problem in my windows application(c#,ms access).i am using backend as ms access.i have written code like this.
string s="datasource=C:\\cms\\cmsaccess.mdb";
string q="select * from users";
OledbConnection con=new OledbConnection(s);
OledbDataAdapter adp=new OledbDataAdapter(q,con);
DataSet ds=new DataSet();
adp.fill(ds,"users");
i have written like this in every form where ever i connected to database.but if i installed in server how the application access that database(C:\\cms\\cmsaccess.mdb) in clients .the database location may be changed in clients.i am facing this problem. this application must be run in network.please send solution for this problem.
thank you
regards
obalesu n
|
|
|
|
|
obalesu wrote: i have written like this in every form where ever i connected to database
Create a DAL - All database related code should go in one location. That location is called a DAL.
obalesu wrote: if i installed in server how the application access that database(C:\\cms\\cmsaccess.mdb) in clients .the database location may be changed in clients.i am facing this problem. this application must be run in network.please send solution for this problem.
Have you thought about using config files?
|
|
|
|
|
thanks for reply,
sir i don't have idea about config files please send clearly.i did not yet solve this problem.please send solution for this problem.and i can i use my application in network system.
regards
obalesu
|
|
|
|
|
obalesu wrote: sir i don't have idea about config files please send clearly
Then you should be reading through a beginners book on the .NET Framework. It will explain much more clearly that I could do in the space of a forum post.
obalesu wrote: please send solution for this problem.and i can i use my application in network system.
I can only send suggestions for such a problem. It is up to you to find the solution. I am not paid to do your work. You are employed as a software developer, I would have said it was a prerequisit to know the basics around the technology in which you are developing. So, I repeat my advise to read a beginners book on the subject.
I also don't know anything about your application. To suggest that I could send you some random piece of code that happens to work with your existing system betrays the depth of your lack of knowledge.
Once you have read that beginners book you might be able to solve your problem yourself, or if not, you will have a better understanding of what the problem actually is.
|
|
|
|
|
Hey,
Does anyone know of any best practices winforms projects in C#? As far as i'm aware all of the microsoft ones (pet shop etc) are ASP.NET? A couple of years ago I searched the web for this and the best I could do was the Tracker project, but it was in VB.
Cheers,
Simon.
|
|
|
|
|
SimonH76 wrote: Does anyone know of any best practices winforms projects in C#?
Best Practices are a fundamental thing. They don't change whether is is ASP.NET or WinForms or a Windows Service and so on.
There may be slightly different patterns for applying those best practices but thats it.
|
|
|
|
|
|
|
|
hi to all,
i m using the sdk editor for Windows CE 6.0 platform
i want to change the settings of default keys like for menu if i access the
popup item of menu using the up down keys and Enter key to select that item.
Instead of these keys i want to use char keys like 'P'key for 'Enter' Key
i hope i'll get the soln
thnx in advance
Pankaj
|
|
|
|
|
I’m trying to emulate the look and feel of something like MS Office Accounting, with a common form layout of two lists of label-control pairs, one at the top left of the form, and the other at the top right. Below these is normally a grid, or other controls that span the whole width of the form, e.g.
-|-
-|-
_|_
___
Now it seems to me that the TableLayoutPanel should be the basis of this, allowing the two top sections to dynamically size as the form sizes horizontally. However, I don’t know whether to use four columns, for left label-control and right label-control, and one row for each two label-control pairs, or to use two columns, and a separate container in each column for a vertical list of label-control pairs.
I’ve never used these layout controls before so any advice will be much appreciated.
|
|
|
|