?
Solved

Vb Grid

Posted on 2014-09-28
3
Medium Priority
?
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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