Solved

Vb Grid

Posted on 2014-09-28
3
182 Views
Last Modified: 2014-10-01
Hi  

I have a Grid that shows selected Dates in Month is colour and any Staff Leave application in different colour
If the user clicks on a leave the program ask if the user wants to delete the leave Yes No

Dim Empno as String = Selected Employee Number from Table
Dim SDate as Sting = Start Date From Table
Dim EDate as String = End Date from Table

if Showmessage("delete Employee " & Empno & " from date " & Sdate " to Date " & eDate ) = Yes then
  Delete from Table
End if
  changeLeaveDate()
end if

how do I get the Empno, SDate and EDate to be seen in the ChangeLeave form
0
Comment
Question by:Kevinfeening
  • 2
3 Comments
 
LVL 20

Expert Comment

by:ElrondCT
ID: 40349293
If I understand you correctly, you want to put a date control (DateTimePicker?) into a DataGrid. I'm aware of three options:

1) Put a regular DateTimePicker into a DataGrid. One example of how to do this (and other types of controls) is at http://www.codeproject.com/Articles/9558/How-to-add-selection-controls-to-your-DataGrid

2) Buy a commercial control designed for this. I've liked Rustemsoft's DataGridColumns .NET assembly (www.rustemsoft.com).

3) Create your own class, using Inherits DataGridColumnStyle. MS actually provides an example of this on the DataGridColumnStyle class documentation page: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridcolumnstyle%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2 shows .NET v4.5, but click on Other Versions if needed.

If I've misunderstood your need, my apologies. Perhaps if you describe a bit more about how your Grid is set up and how you're wanting to make changes, I can provide better assistance.
0
 

Author Comment

by:Kevinfeening
ID: 40349306
Hi ElrondCT

Thanks No I don't need a timepicker

I worked out how to send the Variable values since email

The first Part of the code
if Showmessage("delete Employee " & Empno & " from date " & Sdate " to Date " & eDate ) = Yes then
   Delete from Table

Deletes the record correctly

I want to send the Empno SDate and eDate to a new form with 3 labels and  a Date picker already on it
if the user clicks NO to Delete Employee then using

dim changeDate as New changeLeaveDate()
changeDate.SendVariables(me.Empno, Me.SDate, Me.eDate
changeLeaveDate.show()

in the changeLeaveDate form I have

Public Sub SendVariables(byVal Empno, ByVal SDate, ByVal eDate)
empno, sDate and eDate all have the correct values
end sub

How do I use these variables in the
Public Sub changeLeaveDate_Load(ByVal Sender as System.Object, byVal e As System.EventArgs)

' Set the Label text
label1.text = Empno
label2.text = sDate
label3.text = "End Date"
datetimepicker1.text = eDate

End Sub
0
 
LVL 20

Accepted Solution

by:
ElrondCT earned 500 total points
ID: 40351540
You're doing it in the wrong order. Load happens when the form is first instantiated, so it's already happened before you use your SendVariables method. You can set each of the controls in SendVariables:
Public Sub SendVariables(byVal Empno, ByVal SDate, ByVal eDate)
' Set the Label text
label1.text = Empno
label2.text = sDate
datetimepicker1.text = eDate
end sub

Open in new window

You can also set the values directly, from the parent form, assuming the controls are declared Friend or Public (Friend is the default):
dim changeDate as New changeLeaveDate()
changeDate.label1.text = Empno
changeDate.label2.text = sDate
changeDate.datetimepicker1.text = eDate
changeDate.show()          ' Note the corrected name; show the instance, not the type

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

757 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

19 Experts available now in Live!

Get 1:1 Help Now