Jump to content

First Program

- - - - -

  • Please log in to reply
10 replies to this topic

#1
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Hello

I have a huge problem, well I have read two C# books (Visual C Sharp 2008 by James Foxall and Wiley - C# Bible). Well now I think all my spent time for that is wasted :(:(.

Well let's back to my program and you will see why I am "grunchy" about that :(.
I wanna create a simple Reminder for example I wanna enter the Time when I want it to start, and I wanna select Time when I want it to stop. And ofcourse A simple Text Box where you write your note.

I have created Easy Part and that is a Design View shown in pic. bellow:

Posted Image

Timer is added, just he cant be seen on picture :)

Anyway I have problem, what to do know and how to make this Reminder a working application.

Correct me but my Logic for this is:

1. Select Time/Date at Start Time
2. Select Time/Date at End Time
3. Select How many minutes will this reminder remind you
4. Enter Note
5. Click Start button (Start Timer and wait until it reach End Time)
6. Window Disappear at task bar
7. Window Pop Out when it is time to Remind you

UHhh now comes the most difficult part of my "Journey To C#" I dont know what to write at Program Code, after all I have read.

If someone is willing to Help


Thx

#2
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
hello

I have started my new reminder this is a lil bit simple, all you need to do is type your time when you want it to show you your remind msg.

this is it's design view:

Posted Image

and this is it's code:

Posted Image



Now I have problems:

1. Is this line correct and is it at right place ?
myTime=dateTimePicker1.Value.AddYears(dateTimepicker1.Value.Year)...............................

2. What do I need to enter and where do I need to enter SOME CODE that will start this program

for example I want my program to start when I click START BUTTON, so at this line

private button1_Tick (.........)

I wanna type

timer1.Start;
Form1.Hide;

and probably this is wrong because I get some errors :
Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statemant
Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statemant

So what do I need to enter and where do I need to type so this can start


All i wanna is that when you open program you enter date/time and then when you hit START window hide and msg box will pop out when the REAL date/time is equal to my Selected Time

#3
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Ok, I don't know how good the books you read are but you should practice programming not only learn it. I wrote q short tutorial that might clear out what you don't know, you can find it bellow in my signature. It 17 pages in length only.

Do you know what classes are? Has any of the two books you've read thought you how to use the VS GUI designer?
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#4
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Thx I will look at your tutorial

In these books there is a one program and the whole book is how to create that program and far as I know the best thing that is explained is Design View, but for cods it is already written and poorly explained

#5
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Hi well I have manage to write a code, and it works, but I have another problem. When window pop out I see my Remind msg and if I want to add more mgg and do it all over again I cant I mean If I hit button nothing happened, and ect. it looks like it only works for first time and program stops, I mean you see everything but when you click on any button nothing happens

here is the code


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Podsjetnik
{

public partial class Form1 : Form
{


public Form1()
{
InitializeComponent();

}


private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
if (DateTime.Now > dateTimePicker1 .Value )
{
this.Visible = true;
nova.Show();
timer1.Stop();
}

}

private void Form1_Load(object sender, EventArgs e)
{
timer1.Stop();
}
Form2 nova = new Form2();
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if(nova.ShowDialog () == DialogResult .OK)
{
nova.Visible = false ;
}
}


}
}

#6
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
It shouldn't be hard to edit it if you've already done it initially. There should be some sort of button or event that fires and allows you to "reset" the reminder. Also, just as a side note, please use
 
tags around your code to make it more readable. A neat feature to add would be to allow the user to set up multiple reminders. You could crate a reminder object and have that be part of a reminder collection and keep track of all the reminders that have been set. That might make things more interesting.
-CDG10620
Software Developer

#7
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Thx

I have fix it now it works. But now there is another problem, when my reminder pop's out at the required time my NOTE WINDOW appears, and in that window (FORM) I have button OK and Button Remind me latter, OK button means that when you enter your note and if you press it NOTE WINDOW disappear and that works nicely, but this second BUTTON (REMIND ME LATER) doesnt work. I wanna make that if button is pressed my First window must appear where can I chose time again.

I dont know what CODE should I type in BUTTON2 because it is on second Form ?? I need some Code that will call FORM 1 when I press button in FORM2

thx

#8
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
I would have to see your code to fully understand what you are talking about. Button2 should have the ability to look at the instance of the reminder and "reset" the reminder time.
-CDG10620
Software Developer

#9
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Ok Here is Design View and Code:

Posted Image

Posted Image

Ok now here are the problems I am dealing with:

1. When I enter my note (FORM2) and select my time(FORM1) I need to Start it, and when I hit START button(FORM1) it start and disappear like I wanna. When the time comes Note(FORM2) pop's out, and that's fine, but If I hit OK button on FORM2 nothing happens I mean Everything disappear I wanna that when I hit OK button again that Application is terminated.

2.On FORM2 there is a REMIND ME LATER button, I wanna make when that BUTTON is hit that my first FORM1 appears but FORM2 disappear so I can Chose time again and start it again.

#10
Cipi-Cips

Cipi-Cips

    Newbie

  • Members
  • Pip
  • 7 posts
Does anyone how how to code button (or something else) when you call FORM 1 from FORM 2, that FORM 1 displays only once, because when I click button on FORM 2, FORM1 appears, and If I continue clicking that button it will always show FORM1 in new window so If I click 10 times button to show FORM 1, I get 10 windows on desktop all representing FORM1.

I need when I click button it will show only 1 window no matter how many times I've clicked that button

#11
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
Hey Cipi-Cips,
I know this wont fully explain what you're trying to do. In fact, I'm not entirely sure I know what it is you're trying to do. =)

if you set this.DialogResult = DialogResult.OK; on form two before it disappeared, you'd have it made.

alternatively, just take that condition off..
make it look like this

this.Visible = false;
nova.ShowDialog();
this.Visible = true;

I think your problem of the windows showing or not would be resolved.

I haven't honestly read all your code, there could be some other conditions in there preventing it from showing




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users