MonthCalendar and textbox

Posted on 2006-05-12
Last Modified: 2012-05-05
Hello all,

I do I get a monthcalendar control to populate a textbox, and when the textbox is populated make the textbox search the database for all the information on that date ?

I thank you in advance
Question by:abennett10
    LVL 5

    Expert Comment

    on calendar.change event
    textbox.text = calendar selected value

    on textbox text changed event
     searchDB(textbox.text) <~ call your function here

    this will search everytime they change the date, so if you accidently choose the wrong will still search


    Author Comment

    I don't see a selectedvalue attribute

    Author Comment

    It was actually textbox.text = calendar.SelectionStart.ToShortDateString
    LVL 5

    Expert Comment

    I wasn't sure if you were using a custom control for the calendar, hence the non  specific methods....I was just trying to steer you towards the route of automating the procedure.  Good luck.
    LVL 5

    Expert Comment

    What kind of DB and how are you displaying the returned data?
    LVL 5

    Accepted Solution

    1.  Add a datagrid(dg) to your form.
    2.  Add a button(btnSearch) to your form.
    3.  Connect to your database and return a dataset.
    4.  Bind the datagrid to the dataset.
    5.  When you select a date on the calendar, the date will appear in the textbox.
    6.  Hit the btnSearch and it will search your dataset and return records that match the value in the textbox and appear in     the datagrid.
    7.  DOB in this example is Date Of Birth.

    Imports System
    Imports System.Data
    Imports System.Data.Oledb

    Public Class Form1
        Dim cs As String = "provider=microsoft.jet.oledb.4.0;data source =c:\members.mdb "
        Dim cn As New OleDb.OleDbConnection(cs)
        Dim da As New OleDb.OleDbDataAdapter(" Select * From CreditApplication", cn)
        Dim ds As New DataSet

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            dg.DataSource = ds.Tables(0)
        End Sub

        Private Sub Calendar_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles Calendar.DateChanged
            Dim selectDate As Date = Me.Calendar.SelectionStart
            textbox.Text = selectDate
        End Sub

        Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
            Dim DOB As String = "05/01/2006"

            Dim dv As DataView = ds.Tables(0).DefaultView

            dv.RowFilter = "DOB LIKE '%" + textbox.Text + "%' "

        End Sub

    End Class

    should work for both access and mySql

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now