Results 1 to 7 of 7

Thread: [RESOLVED] [2005] C# -> Vb.net

  1. #1

    Thread Starter
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Resolved [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.

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2005] C -> Vb.net

    I don't know much C either, but isn't this C#?

    http://www.developerfusion.co.uk/uti...sharptovb.aspx

  3. #3

    Thread Starter
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Re: [2005] C# -> Vb.net

    yea, i guess your right. i'll try out the utility.

  4. #4
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  5. #5

    Thread Starter
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    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.

  6. #6

    Thread Starter
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    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:
    1. Private Sub frmDateEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.  
    3.       Dim newDateEdit As MyDateEdit
    4.  
    5.       newDateEdit = New MyDateEdit()
    6.  
    7.       Me.Controls.Add(newDateEdit)
    8.  
    9.    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.

  7. #7

    Thread Starter
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    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
  •  



Click Here to Expand Forum to Full Width