VS2010 calendar control incorrect dates - visual-studio-2010

The following issue is that i have 3 calendar controls (different ID) in a ASP.NET page (Framework 4.0), the calendar control is not visible but when i click a button it opens up and lets you select a date, everything is fine until i open the second calendar control when i chose a different date it sets the previous date (from calendar control 1)
Calendedar control code
Protected Sub Calendar1_AddDataControl_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1_AddDataControl.SelectionChanged
TextBox6_AddDataControl.Text = Calendar1_AddDataControl.SelectedDate.ToShortDateString
Calendar1_AddDataControl.Visible = False
End Sub
Example:
Control 1 Date: 01/14/2013
Control 2 Date: 01/14/2013 but i selected 02/05/2013
Control 3 Date: 01/14/2013 but i seected 02/06/2013
i did my homework trying to read previous questions, looking over the internet and i was unable to find a solution to this, i'm a newbie at coding in ASP.Net using Visual Studio 2010.

I understand your handler methods all have the same body except the TextBox identifier.
When you select a date in your Calendar2_AddDataControl, you want to use its SelectedDate value for the TextBox. The handler method for Calendar2 would look like this:
Protected Sub Calendar2_AddDataControl_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar2_AddDataControl.SelectionChanged
// Display SelectedDate of Calendar_2_
TextBox7_AddDataControl.Text = Calendar2_AddDataControl.SelectedDate.ToShortDateString
Calendar2_AddDataControl.Visible = False
End Sub
assuming it's TextBox7 that should display its selected date.

Related

Zoho Creator -- Get calendar date from calendar report and paste into another form

I have a calendar report. when i click on a date, i want a different form to open, not the form that the calendar report is based on. Then i want the date value from the first form to be passed to the second form. So far, I have this code, on load of the Calendar Form:
MyDate = input.Departure_Date_Time;
//return same window to calendar report
openUrl("https://app.zohocreator.com/ccimailzoho/interhof-travel-
calendar#Calendar","same window");
//open trip form in popup
openurl("#Form:Trip_Form","popup window");
//Trip_Form.Departure_Date_Time = MyDate;
But it doesn't work; MyDate variable does not hold the value between the two forms. Any ideas?
For future viewers, if you want to set a value of a form on open from a different form, you can set the value directly in the openurl statement:openurl("#Form:Trip_Form?Departure_Date_Time=" + input.Departure_Time + "&Arrival_Date_Time=" + input.Departure_Time,"same window");

Outlook 2013 Addin: Change Ribbon Button Image on click of button using c#

I have created Ribbon button for Outlook 2013 using c#.
And i have also set image for the ribbon.
Now on click of Ribbon button i want to change Ribbon Image.
Is it possible to achieve this using c#.?
Not sure how exactly you want it to work, but this could do the trick.
bool callback {get;set}
public Bitmap GetImage(IRibbonControl control)
{
switch (control.Id)
{
case "FooButtonId":
{
if(callback== true){
callback = false;
return new Bitmap(Properties.Resources.someimage1);
}else
callback =true;
return new Bitmap(Properties.Resources.someimage2);
}
}
}
}
This question is 3 yo but helped me to go further and I want to share this with you.
First, I accomplished this in VB.net so my code will be in VB.net. There are some online tools to convert the code into C#.
Second, I used a Toggle button instead of a Simple button.
Third, I used OnOff as a project setting in order to save the state of the Toggle button.
Step 1: Ribbon.xml file, code to place the toggle button on the ribbon.
Assuming you already have set up the tab and group tags in the file.
<toggleButton id="onoffTBTN" label="ON/OFF" showImage="true" onAction="OnOffToggle" getImage="OnOffImage"/>
Step 2: Ribbon.vb file, code to change the OnOff setting based on the Toggle button status(pressed or not) and forces to invalidate the custom control
Public Sub OnOffToggle(ByVal control As Office.IRibbonControl, ByVal pressed As Boolean)
My.Settings.OnOff = pressed
My.Settings.Save()
myRibbon.InvalidateControl("onoffTBTN")
End Sub
Step 3: Ribbon.vb file, reads the OnOff setting and changes the image accordingly. Have in mind that your images must have been added to your project resources in order to use them at My.Resources.*. I used png files that support transparent pixels. This function is called in two occasions, first when the Outlook starts and second when the toggle button is pressed and specifically with the command myRibbon.InvalidateControl("onoffTBTN").
Public Function OnOffImage(ByVal control As Office.IRibbonControl) As Drawing.Bitmap
Dim onoff As Boolean = My.Settings.OnOff
Select Case control.Id
Case "onoffTBTN"
If onoff = True Then
Return New Drawing.Bitmap(My.Resources._on)
Else
Return New Drawing.Bitmap(My.Resources.off)
End If
End Select
End Function
The only weird behaviour is when the OnOff setting has been set to TRUE. The correct image is displayed but the Toggle button looks unpressed. You have to click twice in order to set the OnOff setting to False.

get cursor position another form in windows application

I have two form in my application i am calling two form together from master page.i wrote code in my master page
in top i declared like this
Dim form As New FrmDelivary
Dim frm1 As New FrmrecievedDelivaryRequest
in toolstrip menu event like this:
Dim frm1 As New FrmrecievedDelivaryRequest
frm1.Location = New Point(625, 225)
frm1.MdiParent = Me
frm1.Show()
Dim frm2 As New FrmDelivary
frm2.Location = New Point(965, 0)
frm2.MdiParent = Me
frm.show()
if i press R i want to go my cursor the particular textbox of FrmrecievedDelivaryRequest
if i press D i want to go my cursor the particular textbox of FrmDelivary
How can I do this? i trey something like this in frmMaster_KeyDown event: but same page is showing again. I have already open instance of FrmDelivary, so I don't want to show same page again. I want to just get cursor position to particular textbox of this form
If e.KeyCode = Keys.A Then
form.Show()
form.txtTicket.Focus()
Cursor.Position = form.txtTicket.Location
end if
I am working on vb.net windows application
After
frm1.Show()
place
frm1.txtTicket.Focus()
I don't think you need the Cursor.Position call
Set your frm1 and frm2 variables at the top of the code window so they are accessible from all of the Subs. In your KeyDown event, put
If e.KeyCode = Keys.A Then
frm1.Show()
frm1.txtTicket.Focus()
Cursor.Position = frm1.txtTicket.Location
end if
The problem is that you are instantiating a new copy of the form with the "AS NEW frmDelivery" statement.

What event will fire each time a report is previewed/printed?

I would like to evauluate the value of a textbox report control and hide or display it based on its value, which I can achieve easily with VBA:
If Me.Fixed.Value = 0 Then
Me.Fixed.Visible = False
End If
That works fine, but the query I am using as the report's record source allows a range of records to be printed all at once (1 per page/report), and I want the above code to run for each page/report. I am unsure of where to put the code so that each record will play by the rules. Currently, if I choose a range of 8 records, only the first one does what I want, and as I navigate through the other records in the print preview screen the format of the report is remaining unchanged when it should be changing.
I have tried the following events:
Report:
On Current
On Load
On Got Focus
On Open
On Activate
On Page
Section:
On Format
On Print
On Paint
Where can I put my VBA so that each time I scroll through/navigate the range of records returned on that report my code runs?
You need to set the Visible property back to True as well, otherwise it will remain invisible.
I'm using the Format event of the Details section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Fixed = 0 Then
Me.Fixed.Visible = False
Else
Me.Fixed.Visible = True
End If
End Sub
This works in Print Preview but not in Report View. There is probably a way to get this to work with the Report View, but I never use this view.
The statement can be simplified:
Me.Fixed.Visible = Not (Me.Fixed = 0)
Note that the Visible property is not available in the Detail_Paint() event, which is the event you need to use to have the conditional formatting apply in Report View. (Which might be required if you are trying to do something fancy such as simulated hyperlinks for a drill-down effect.)
A workaround is to set the ForeColor of the text box to equal the BackColor. Although the text is technically still there, it does not "show" on the displayed report, thus simulating a hidden field.
Private Sub Detail_Paint()
' Check for even numbers
If (txtID Mod 2 = 0) Then
txtID.ForeColor = vbBlack
Else
' Set to back color to simulate hidden or transparent.
' (Assuming we are using a Normal BackStyle)
txtID.ForeColor = txtID.BackColor
End If
End Sub
Example Output:

Scroll Bar Issues Automatically Scrolling Down To The Last Control

Alright, I designed a form to fit onto the current screen size I use, with the form having a vertical scroll bar to view items further down on the form.
At the bottom of the form, I have a couple of checkboxes a user has to select before clicking the submit button.
Once the user hits the submit buttom, the user can't scroll back up to the beginning of the form. The user can scroll back up, but when they stop scroll, it scrolls to the bottom where the last checkbox was checked off.
I assume by checking this last checkbox is that's setting the focus of that control?
Any suggestions on how to fix the scrolling issue?
Keep a note of the last scroll position, and reapply it on Form_Activate
Try this:
'' Declare at form level
Private LastAutoScrollPos As System.Drawing.Point
Private Sub Form1_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
Me.AutoScrollPosition = LastAutoScrollPos
End Sub
Private Sub Form1_Scroll(sender As Object, e As System.Windows.Forms.ScrollEventArgs) Handles Me.Scroll
If e.ScrollOrientation = ScrollOrientation.VerticalScroll Then
LastAutoScrollPos = New Point(LastAutoScrollPos.X, e.NewValue)
ElseIf e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
LastAutoScrollPos = New Point(e.NewValue, LastAutoScrollPos.Y)
End If
End Sub

Resources