|
-
Aug 7th, 2007, 10:45 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] C# -> Vb.net
Code:
public class MyVistaDateEditCalendar : VistaDateEditCalendar
{
public MyVistaDateEditCalendar(RepositoryItemDateEdit item, object editDate) : base(item, editDate) { }
protected override void Init()
{
base.Init();
this.View = DateEditCalendarViewType.YearInfo;
}
public override void OnItemClick(DevExpress.XtraEditors.Calendar.CalendarHitInfo hitInfo)
{
DayNumberCellInfo cell = hitInfo.HitObject as DayNumberCellInfo;
if (View == DateEditCalendarViewType.YearInfo)
{
DateTime dt = new DateTime(DateTime.Year, cell.Date.Month, CorrectDay(DateTime.Year, cell.Date.Month, DateTime.Day), DateTime.Hour, DateTime.Minute, DateTime.Second);
OnDateTimeCommit(dt, false);
}
else
base.OnItemClick(hitInfo);
}
}
public class MyVistaPopupDateEditForm : VistaPopupDateEditForm
{
public MyVistaPopupDateEditForm(DateEdit ownerEdit) : base(ownerEdit) { }
protected override DateEditCalendar CreateCalendar() {
return new MyVistaDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue);
}
}
public class MyDateEdit : DateEdit
{
protected override PopupBaseForm CreatePopupForm()
{
if (Properties.VistaDisplayMode == DevExpress.Utils.DefaultBoolean.True)
return new MyVistaPopupDateEditForm(this);
return new PopupDateEditForm(this);
}
}
What it does is takes a date editor and stops it from going to the day view, but selects the month. It is using Developer Express, but I really just don't understand the syntax of C#.
Last edited by NPassero; Aug 7th, 2007 at 10:51 AM.
Reason: c sharp, not c.
-
Aug 7th, 2007, 10:50 AM
#2
-
Aug 7th, 2007, 10:51 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] C# -> Vb.net
yea, i guess your right. i'll try out the utility.
-
Aug 7th, 2007, 10:52 AM
#4
Re: [2005] C# -> Vb.net
ok, that is not C it is C# which is very different. I ran the code through a free online translator Found Here and came up with this
Code:
Public Class MyVistaDateEditCalendar
Inherits VistaDateEditCalendar
Public Sub New(ByVal item As RepositoryItemDateEdit, ByVal editDate As Object)
MyBase.New(item, editDate)
End Sub
Protected Overloads Overrides Sub Init()
MyBase.Init()
Me.View = DateEditCalendarViewType.YearInfo
End Sub
Public Overloads Overrides Sub OnItemClick(ByVal hitInfo As DevExpress.XtraEditors.Calendar.CalendarHitInfo)
Dim cell As DayNumberCellInfo = TryCast(hitInfo.HitObject, DayNumberCellInfo)
If View = DateEditCalendarViewType.YearInfo Then
Dim dt As New DateTime(DateTime.Year, cell.[Date].Month, CorrectDay(DateTime.Year, cell.[Date].Month, DateTime.Day), DateTime.Hour, DateTime.Minute, DateTime.Second)
OnDateTimeCommit(dt, False)
Else
MyBase.OnItemClick(hitInfo)
End If
End Sub
End Class
Public Class MyVistaPopupDateEditForm
Inherits VistaPopupDateEditForm
Public Sub New(ByVal ownerEdit As DateEdit)
MyBase.New(ownerEdit)
End Sub
Protected Overloads Overrides Function CreateCalendar() As DateEditCalendar
Return New MyVistaDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue)
End Function
End Class
Public Class MyDateEdit
Inherits DateEdit
Protected Overloads Overrides Function CreatePopupForm() As PopupBaseForm
If Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.[True] Then
Return New MyVistaPopupDateEditForm(Me)
End If
Return New PopupDateEditForm(Me)
End Function
End Class
-
Aug 7th, 2007, 11:01 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] C# -> Vb.net
Thanks for scolding me that it's C#, and i'll try those out see if I can get them working.
-
Aug 7th, 2007, 11:22 AM
#6
Thread Starter
Hyperactive Member
Re: [2005] C# -> Vb.net
Got all the classes lined up, and now I am trying to implement it, but it keeps bombing out..
VB.NET Code:
Private Sub frmDateEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newDateEdit As MyDateEdit
newDateEdit = New MyDateEdit()
Me.Controls.Add(newDateEdit)
End Sub
It adds it fine, but when I click on the drop down to open the date picker it bombs out, with this "Object reference not set to an instance of an object." In the frmDateEdit.Designer.vb
Last edited by NPassero; Aug 7th, 2007 at 11:31 AM.
-
Aug 7th, 2007, 11:31 AM
#7
Thread Starter
Hyperactive Member
Re: [2005] C# -> Vb.net
Seems to have got it working, I need to hardcode the setting so that the VistaDisplayMode = True.. Not sure why it blows up on my otherwise though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|