Click here to Skip to main content
11,410,129 members (60,336 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi dear!
i am developing an application to save some timings using datetimepikcer.
but the issue is.
i am not able to access datetimepicker name or its value in .cs file.

if any idea pleas help

THANX

M USman
Posted 27-Dec-12 19:52pm
Comments
Suvabrata Roy at 28-Dec-12 0:55am
   
Please provide some code sample...
Sergey Alexandrovich Kryukov at 28-Dec-12 0:58am
   
Not clear. A DateTimePicker is used for picking a time, not for saving. :-)

"Name or its value"? Sounds like you have no clue what are main programming entities: types, objects (instances), references, variables, names... I would suggest you learn it all on some more simple examples, without any UI...

—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
I think those will help you

Solution in Windows :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace TimePickerApplication
{
    public class Form1 : Form
    {
        public Form1()
        {
            InitializeTimePicker();
        }
        private DateTimePicker timePicker;
 
        private void InitializeTimePicker()
        {
            timePicker = new DateTimePicker();
            timePicker.Format = DateTimePickerFormat.Time;
            timePicker.ShowUpDown = true;
            timePicker.Location = new Point(10, 10);
            timePicker.Width = 100;
            Controls.Add(timePicker);
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }
 
    }
}

Solution in Web

DateTimePicker Web Control[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi dear i found what the exact issue was.
in properties window i select the property

GenerateMember=false
when i set this property true

GenerateMember=true

i am able to access this in .cs file.

thanx for helping

specail thanx to
Suvabrata Roy
  Permalink  
Comments
Suvabrata Roy at 28-Dec-12 2:13am
   
You most welcome...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Yes dear thanx

you answer is 100% correct
I also tried like this it is working but the issue is

Why i am not able to access datetimepicker value which added using tools(drag drop).


Thanx
  Permalink  
Comments
Suvabrata Roy at 28-Dec-12 1:06am
   
So you are working with windows app?

Right Click on DateTime Picker go to properties go to name, then try to write the code with that name, you can face some cross thread access problem if you trying to access that from other than main thread, then use delegates or MethodInvoke delegate
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Some code example is here?
pleas take a look

 private void btnSave_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure! you want to save changes of prayer timings", "Prayer Timings", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                btnModify.Visible = true;
                btnSave.Visible = false;
                if(!Directory.Exists(Application.StartupPath + "\\PrayerTimings"))
                    Directory.CreateDirectory(Application.StartupPath + "\\PrayerTimings");
                StreamWriter writer = new StreamWriter(Application.StartupPath + "PrayerTimings");
                string strFajar = dtPickerFajar.value?????       //here i want to access value of dtPickerFajar values which is not accessable
                string strZohar = dtPickerZohar.value?????         //5 more same not accessable 
                    //
          
            }
        }
  Permalink  
Comments
Suvabrata Roy at 28-Dec-12 2:06am
   
If you have any query please write in comments area not in solution.
Enjoy Coding... :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

private void btnSave_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Are you sure! you want to save changes of prayer timings", "Prayer Timings", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
btnModify.Visible = true;
btnSave.Visible = false;
if(!Directory.Exists(Application.StartupPath + "\\PrayerTimings"))
Directory.CreateDirectory(Application.StartupPath + "\\PrayerTimings");
StreamWriter writer = new StreamWriter(Application.StartupPath + "PrayerTimings");
string strFajar = dtPickerFajar.value.ToString("dd MMM yyyy"); //here i want to access value of dtPickerFajar values which is not accessable
string strZohar = dtPickerZohar.value.ToString("dd MMM yyyy"); //5 more same not accessable
//

}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 169
1 OriginalGriff 110
2 Maciej Los 68
3 BillWoodruff 60
4 Philippe Mori 60
0 Sergey Alexandrovich Kryukov 8,755
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web02 | 2.8.150414.5 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100