Showing posts with label Janus Systems. Show all posts
Showing posts with label Janus Systems. Show all posts
  • Changing the background color of the rows in the Schedule [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show how to change the background color of the rows in the Schedule control using the WorkingHourSchema object





    The following code shows how to format the rows based on the day of the week





    In VB:



    'Create a new ScheduleHourRange object to specify the format style settings and the

    'time and days when the format style will be applied

    Dim hourRange As New ScheduleHourRange()



    'Specify the start and end time that you want to format

    hourRange.EndTime = New TimeSpan(10, 0, 0)

    hourRange.StartTime = New TimeSpan(8, 0, 0)



    'Specify the days of the week that you want to format

    hourRange.DayOfWeek = ScheduleDayOfWeek.Monday Or ScheduleDayOfWeek.Tuesday Or _

    ScheduleDayOfWeek.Wednesday Or ScheduleDayOfWeek.Thursday Or ScheduleDayOfWeek.Friday



    'Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red



    'Add the ScheduleHourRange to the WorkingHoursRange collection of the WorkingHourSchema

    Me.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange)







    In C#



    //Create a new ScheduleHourRange object to specify the format style settings and the

    //time and days when the format style will be applied

    ScheduleHourRange hourRange = new ScheduleHourRange();



    //Specify the start and end time that you want to format

    hourRange.EndTime = new TimeSpan(10, 0, 0);

    hourRange.StartTime = new TimeSpan(8, 0, 0);



    //Specify the days of the week that you want to format

    hourRange.DayOfWeek = ScheduleDayOfWeek.Monday | ScheduleDayOfWeek.Thursday | ScheduleDayOfWeek.Wednesday | ScheduleDayOfWeek.Thursday | ScheduleDayOfWeek.Friday;



    //Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red;



    //Add the ScheduleHourRange to the WorkingHoursRange collection of the WorkingHourSchema

    this.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange);









    The following code shows how to use the Exceptions collection to format the rows for a specific Date



    In VB:



    'Create a new WorkingHourException

    Dim exception As New WorkingHourException()



    'Specify the date range where you want to give the format

    'Note: The date range must be of at least one day, and use the StartTime and EndTime 'properties of the HourRange to set the time of the day where the format will be applied

    exception.DateRange = New DateRange(New DateTime(2006, 1, 15), New DateTime(2006, 1, 16))



    'Specify the start and end time that you want to format exception.HourRange.EndTime = New TimeSpan(14, 0, 0)

    exception.HourRange.StartTime = New TimeSpan(10, 0, 0)

    'Set the format style that you want to apply

    exception.HourRange.FormatStyle.BackColor = Color.Red



    'Add the WorkingHourException to the Exceptions collection of the WorkingHourSchema

    Me.Schedule1.WorkingHourSchema.Exceptions.Add(exception)





    In C#



    //Create a new WorkingHourException

    WorkingHourException exception = new WorkingHourException();



    //Specify the date range where you want to give the format

    //Note: The date range must be of at least one day, and use the StartTime and EndTime //properties of the HourRange to set the time of the day where the format will be applied

    exception.DateRange = new DateRange(new DateTime(2006, 1, 16), new DateTime(2006, 1, 17));



    //Specify the start and end time that you want to format

    exception.HourRange.EndTime = new TimeSpan(14, 0, 0);

    exception.HourRange.StartTime = new TimeSpan(10, 0, 0);

    //Set the format style that you want to apply

    exception.HourRange.FormatStyle.BackColor = Color.Green;



    //Add the WorkingHourException to the Exceptions collection of the WorkingHourSchema

    this.Schedule1.WorkingHourSchema.Exceptions.Add(exception);







    The following code shows how to use the RecurrencePattern property of the ScheduleHourRange object to apply the format style for the rows based on a recurrence pattern



    In VB:



    Dim recurrencePattern As New WorkingHourRecurrencePattern()

    'Call the BeginEdit before changing the properties of the RecurrencePattern

    recurrencePattern.BeginEdit()





    'Specify the recurrence pattern. In this case the 10th of every month is the date that 'will be formatted

    recurrencePattern.SetDefaultValuesForDate(DateTime.Today)

    recurrencePattern.PatternStartDate = DateTime.Today

    recurrencePattern.RecurrenceEndMode = RecurrenceEndMode.NoEndDate

    recurrencePattern.RecurrenceType = RecurrenceType.Monthly

    recurrencePattern.StartTime = New TimeSpan(8, 0, 0)

    recurrencePattern.EndTime = New TimeSpan(10, 0, 0)

    recurrencePattern.DayOfMonth = 10



    recurrencePattern.EndEdit()



    'Create the new ScheduleHourRange that will be added to the WorkingHourSchema

    Dim hourRange As New ScheduleHourRange()



    'Set the RecurrencePattern that will be used

    hourRange.RecurrencePattern = recurrencePattern



    'Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red



    'Add the ScheduleHourRange to the WorkingHourSchema of the Schedule

    Me.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange)





    In C#



    WorkingHourRecurrencePattern recurrencePattern = new WorkingHourRecurrencePattern();

    //Call the BeginEdit before changing the properties of the RecurrencePattern

    recurrencePattern.BeginEdit();



    //Specify the recurrence pattern. In this case the 10th of every month is the date that //will be formatted

    recurrencePattern.SetDefaultValuesForDate(DateTime.Today);

    recurrencePattern.PatternStartDate = DateTime.Today;

    recurrencePattern.RecurrenceEndMode = RecurrenceEndMode.NoEndDate;

    recurrencePattern.RecurrenceType = RecurrenceType.Monthly;

    recurrencePattern.StartTime = new TimeSpan(8, 0, 0);

    recurrencePattern.EndTime = new TimeSpan(10, 0, 0);

    recurrencePattern.DayOfMonth = 10;



    recurrencePattern.EndEdit();



    //Create the new ScheduleHourRange that will be added to the WorkingHourSchema

    ScheduleHourRange hourRange = new ScheduleHourRange();



    //Set the RecurrencePattern that will be used

    hourRange.RecurrencePattern = recurrencePattern;



    //Set the format style that you want to apply

    hourRange.FormatStyle.BackColor = Color.Red;



    //Add the ScheduleHourRange to the WorkingHourSchema of the Schedule

    this.Schedule1.WorkingHourSchema.WorkingHoursRange.Add(hourRange);







    If you want to modify only the rows of a particular owner then use the WorkingHourSchema property of the ScheduleAppointment owner to add the ScheduleHourRange



    In VB:



    Dim owner As ScheduleAppointmentOwner = Me.Schedule1.Owners(0)

    owner.WorkingHourSchema.WorkingHoursRange.Add(hourRange)



    In C#



    ScheduleAppointmentOwner owner = this.Schedule1.Owners[0];

    owner.WorkingHourSchema.WorkingHoursRange.Add(hourRange);


    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using a layout file to preserve user changes [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use a layout file to preserve Schedule control settings. Using a layout file you could be able to preserve even the changes to the layout made by the user.


    Follow these steps to use a layout file at run time:



    1) Define the layout at design time and then save it clicking in the "Save Layout File" button that is found in the "Layout Manager" tab of the Schedule control designer.



    2) In the Load event of the form, load the layout from a file using the LoadLayoutFile method of the Schedule.



    In VB:



    Private Sub LoadLayout()

    Dim layoutDir As String = "C:\ScheduleLayout.xml"

    Dim layoutStream As FileStream = New FileStream(layoutDir, FileMode.Open)

    Schedule1.LoadLayoutFile(layoutStream)

    layoutStream.Close()

    End Sub



    In C#:



    private void LoadLayout()

    {

    string layoutDir = @"C:\ScheduleLayout.xml";

    FileStream layoutStream;

    FileInfo fInfo = new FileInfo(layoutDir);

    if (fInfo.Exists)

    {

    layoutStream = new FileStream(layoutDir, FileMode.Open);

    schedule1.LoadLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }



    3) (Optional) To preserve user changes to the layout, update the layout before it is changed in the CurrentLayoutChanging event of the Schedule.



    In VB:



    Private Sub Schedule1_CurrentLayoutChanging(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Schedule1.CurrentLayoutChanging

    'To persist user changes in the current layout,

    'call the Update method explicitly before changing the layout

    If Not Schedule1.CurrentLayout Is Nothing Then

    Schedule1.CurrentLayout.Update()

    End If

    End Sub





    In C#:



    private void schedule1_CurrentLayoutChanging(object sender, System.ComponentModel.CancelEventArgs e)

    {

    //To persist user changes in the current layout,

    //call the Update method explicitly before changing the layout

    if (schedule1.CurrentLayout != null)

    {

    schedule1.CurrentLayout.Update();

    }

    }



    4) In the Closing event of the form, save the layout file again to be able to preserve the changes the user did (like view, format settings, dates, etc).



    In VB:



    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

    Dim Result As DialogResult

    Dim LayoutDir As String

    Dim LayoutStream As FileStream



    Result = MessageBox.Show("Do you want to preserve the changes in the Schedule control layout?", "Preserve changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)

    If Result = Windows.Forms.DialogResult.Cancel Then

    e.Cancel = True

    ElseIf Result = Windows.Forms.DialogResult.Yes Then

    LayoutDir = "C:\ScheduleLayout.xml"

    LayoutStream = New FileStream(LayoutDir, FileMode.Open)

    Schedule1.SaveLayoutFile(LayoutStream)

    LayoutStream.Close()

    End If

    End Sub



    In C#:



    private void Form1_FormClosing(object sender, FormClosingEventArgs e)

    {



    DialogResult result;

    string layoutDir;

    FileStream layoutStream;



    result = MessageBox.Show("Do you want to preserve the changes in the Schedule control layout?", "Preserve changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);



    if (result == DialogResult.Cancel)

    {

    e.Cancel = true;

    }

    else if (result == DialogResult.Yes)

    {

    layoutDir = + @"C:\ScheduleLayout.xml";

    layoutStream = new FileStream(layoutDir, FileMode.Open);

    schedule1.SaveLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }

    5) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using multiple layouts [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use multiple layouts in a Schedule control.



    Follow these steps to create multiple layouts at design time:



    1) Create a new Visual Basic or C# project using "Windows Application" Template



    2) Add a Schedule control to Form1.



    3) In the Designer window of the Schedule control, modify the layout as you want, changing the view, dates, owner, etc.



    4) Select the "Layout Manager" Tab. A List View will appear with a "Draft Layout" in it. The Draft Layout contains the changes you just made to the Schedule but it is not saved as a layout in the Layouts collection.



    5) Click on "Save Current Layout" button and set the name "MonthView" to the draft layout.



    6) Once the "MonthView" layout has been saved, add a new layout for products. To add a new layout click on the "New Layout" button and Layout1 will appear.



    7) Change the name of Layout1 for "WeekView".



    8) Double click in the "WeekView" layout to select this empty layout. This action will set the "WeekView" layout you just created as the CurrentLayout in the Schedule control and all the changes you do will affect this layout only.



    9) Change any properties in the new layout like view or owners.



    10) Select "Layout Manager" Tab again.



    11) Click in the "New Layout" button and Layout1 will appear.



    12) Change the name of Layout1 for "WorkWeek".



    13) Double click in the "WorkWeek" layout to select this empty layout. This action will set the "WorkWeek" layout you just created as the CurrentLayout in the Schedule control and all the changes you do will affect this layout only.



    14) Change any properties in the new layout like view or owners.



    15) You have finished adding layouts for the tutorial. To change a property in any of the layouts you have in the Layouts collection, select the layout from Layouts combo in the tool bar of the Schedule designer.



    16) To select a layout at run time use the CurrentLayout property of the Schedule class. In the tutorial we are going to do that using buttons. So, add a button "Button1" and

    change its Text property to "Show MonthView". In the Click event for this button write the following code that set the "MonthView" layout as the current layout in the Schedule control:



    In VB:



    If Schedule1.CurrentLayout Is Nothing OrElse Schedule1.CurrentLayout.Key <> "MonthView" Then

    Schedule1.CurrentLayout = Schedule1.Layouts("MonthView")

    End If



    In C#



    if (schedule1.CurrentLayout==null || schedule1.CurrentLayout.Key!="MonthView")

    {

    schedule1.CurrentLayout = schedule1.Layouts["MonthView"];

    }



    17) Add a buttons to show "WeekView" and "WorkWeek" layouts with similar code in the Click event for those buttons.





    18) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Saving and Loading Appointments from a stream [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to save and load the Appointments, Fields and Owners collections from a stream.



    The steps followed to create this project were:



    1) Create a new Visual Basic or C# project using "Windows Application" Template



    2) Add a Schedule control to Form1.



    3) Add a Calendar control and bind it to the Schedule control.



    4) Add a button and change its Text property to "Save"



    5) In the Click event of the save button use the SaveAppointments method to save the appointments to a file.



    In C#



    this.Cursor = Cursors.WaitCursor;

    string appointmentsDir = @"C:\Appointments.xml";

    System.IO.FileStream appointmentsStream;

    appointmentsStream = new System.IO.FileStream(appointmentsDir, System.IO.FileMode.Create);

    schedule1.SaveAppointments(appointmentsStream);

    appointmentsStream.Close();

    this.Cursor = Cursors.Default;





    In VB



    Me.Cursor = Cursors.WaitCursor

    Dim appointmentsDir As String = "C:\Appointments.xml"

    Dim appointmentsStream As System.IO.FileStream

    appointmentsStream = New System.IO.FileStream(appointmentsDir, System.IO.FileMode.Create)

    Schedule1.SaveAppointments(appointmentsStream)

    appointmentsStream.Close()

    Me.Cursor = Cursors.Default



    6) Add a button and change its Text property to "Load"



    7) In the Click event of the load button, use the LoadAppointments method of the Schedule to load the appointment from a file



    In VB



    Me.Cursor = Cursors.WaitCursor

    Dim AppointmentsDir As String = "C:\Appointments.xml"

    Dim AppointmentsStream As System.IO.FileStream

    AppointmentsStream = New System.IO.FileStream(AppointmentsDir, System.IO.FileMode.Open)

    Schedule1.LoadAppointments(AppointmentsStream)

    AppointmentsStream.Close()

    Me.Cursor = Cursors.Default

    In C#



    this.Cursor = Cursors.WaitCursor;

    string appointmentsDir = @"C:\Appointments.xml";

    System.IO.FileStream appointmentsStream;

    appointmentsStream = new System.IO.FileStream(appointmentsDir, System.IO.FileMode.Open);

    schedule1.LoadAppointments(appointmentsStream);

    appointmentsStream.Close();

    this.Cursor = Cursors.Default;


    8) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Working with Multiple Appointment Owners in a Schedule control [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show how to handle appointments for more than one person.



    1) Create a new "Windows Application" Project.



    2) Drag a Schedule control from the toolbox into the Form designer.



    3) Select the Schedule control in the Form and set the MultiOwner property to true in the properties window.



    4) Right click in the Schedule control and select "Schedule Designer" menu. In the Schedule Designer dialog select Owners node.



    5) In the Owners panel, Click Add button to add a new owner. Select the new owner and set the following properties in the properties window.

    Text = John Doe

    Value = Doe



    6) Add another owner with the following properties values.

    Text = Peter Barker

    Value = Barker



    Note: In design time the Value property of the ScheduleAppointmentOwner can only be a string. Set the Value in code if you want a different type.



    7) In code create two appointments and add them to the Schedule control.



    In C#



    DateTime startDate = this.schedule1.Date.AddHours(8);



    ScheduleAppointment app1 = new ScheduleAppointment(startDate, startDate.AddMinutes(30), "Phone Call");

    ScheduleAppointment app2 = new ScheduleAppointment(startDate, startDate.AddMinutes(30), "Go to the dentist");



    //The Owner property of the Appointment must be equal to the Value property of //one of the AppointmentOwners in the Schedule control.

    app1.Owner = "Doe";

    app2.Owner = "Barker";



    this .schedule1.Appointments.Add(app1);

    this .schedule1.Appointments.Add(app2);





    In VB



    Dim startDate As DateTime = Me.Schedule1.Date.AddHours(8)



    Dim app1 As ScheduleAppointment = New ScheduleAppointment(startDate, startDate.AddMinutes(30), "Phone Call")

    Dim app2 As ScheduleAppointment = New ScheduleAppointment(startDate, startDate.AddMinutes(30), "Go to the dentist")



    'The Owner property of the Appointment must be equal to the Value property of

    'one of the AppointmentOwners in the Schedule control.

    app1.Owner = "Doe"

    app2.Owner = "Barker"



    Me.Schedule1.Appointments.Add(app1)

    Me.Schedule1.Appointments.Add(app2)



    8) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using SchedulePrintDocument to Print the Control [Janus GridEX WinForms Control v3.5 for .NET] The SchedulePrintDocument component allows the developer to print the contents of a Schedule control. In this tutorial, we use a SchedulePrintDocument to provide the application with Print Preview capabilities.



    The steps followed to create this project were:



    1) Open Form1 in Design mode



    2) Drag a Schedule control from the Toolbox into the Form designer



    3) Drag a SchedulePrintDocument component from the Toolbox and drop it over Form1



    4) Select SchedulePrintDocument1 component in the Components tray and set the Schedule property equal to schedule1



    5) Drag a PrintPreviewDialog component from the Toolbox and drop it over Form1



    6) Set the Document property of PrintPreviewDialog1 equal to SchedulePrintDocument1



    7) Add a button and change its Text property to "Print Preview..."



    8) In the Click event of the button, call The ShowDialog method of the PrintPreviewDialog1 component.



    9) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Schedule and Calendar controls working together [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use a Calendar control as the date navigator for a Schedule control bound to it.



    Follow these steps to reproduce this sample:



    1) Create a new Visual Basic or C# project using "Windows Application" Template



    2) Add a Schedule Control to a tab in the Toolbox window by right clicking in the Toolbox window and choosing "Choose Items..." menu. When the dialog appears, select ".Net Framework Components" tab, check "Schedule" control in the list and click OK.



    Note: If the Schedule control doesn't appear as an option in the list, click the Browse button and open Janus.Windows.Schedule.dll.



    3) Drag a Schedule control from the toolbox into the Form designer.



    4) Add a Calendar Control to a tab in the Toolbox window by right clicking in the Toolbox window and choosing "Choose Items..." menu. When the dialog appears, select ".Net Framework Components" tab, check "Calendar" control in the list and click OK.



    Note: If the Calendar control doesn't appear as an option in the list, click the Browse button and open Janus.Windows.Schedule.v3.dll.



    5) Drag a Calendar control from the toolbox into the Form designer.



    6) Select the Calendar control and set the following properties in the properties window:



    Schedule = schedule1

    SelectionStyle = Schedule



    7) Set the AllowDrop property of the Calendar control to true in order to allow the user to drop appointments from the Schedule to any date in the Calendar.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Binding the Schedule Control to a DataSource [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to bind the Schedule control to a DataSource available at design time.



    Follow these steps to create a simple form using a Schedule control to display records from a table in a database.



    1) Create a new Visual Basic or C# project using "Windows Application" Template



    2) Add a new Data Source to the application:



    Click in the "Add New Data Source..." menu under "Data" and follow the wizard to add "Appointments" table from Schedule.mdb database.



    In the tutorial we used Provider = "Microsoft Access Database File (OLE DB)" and Database file name = "C:\Schedule.mdb".



    3) Build the project to be able to see ScheduleDataSet and AppointmentsTableAdapter as components in the Toolbox.



    4) Drag from the tool box ScheduleDataSet and AppointmentsTableAdapter components to the designer.



    Now that the DataSet has been created, we can start using the TimeLine control in the project.



    5) Add a Schedule Control to a tab in the Toolbox window by right clicking in the Toolbox window and choosing "Choose Items..." menu. When the dialog appears check "Schedule" control in the list and click OK.



    Note: If Schedule control doesn't appear as an option in the list, click the Browse button and open Janus.Windows.Schedule.dll.



    6) Drag a Schedule control from the toolbox into the Form designer.



    7) Select the Schedule control in the Form and set the following properties in the properties window:



    DataSource = scheduleDataSet1

    DataMember = Appointments

    StartTimeMember = StartDate

    EndTimeMember = EndDate

    TextMember = Subject



    8) (Optional) Right click on the Schedule control and select "Retrieve Fields" menu. This action will force the control to read the data source structure and create the fields for the items in the table.



    9) In the Load event of the Form fill the Appointments table in the dataset with the following code:

    In VB.Net

    Me.AppointmentsTableAdapter1.Fill(Me.ScheduleDataSet1.Appointments)


    In C#.Net

    this.appointmentsTableAdapter1.Fill(this.scheduleDataSet1.Appointments)


    10) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using a layout file to preserve user changes [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to save and load a layout file to preserve ExplorerBar
    control settings.

    Using a layout file you could be able to preserve even the changes to the layout
    made by the user.


    The steps followed to create this project were:


    1) Create a new Visual Basic or C# project using "Windows Application" Template.

    2) Add a ExplorerBar control to Form1.

    3) Add a button and change its Text property to "Load".

    4) In the Click event of the load button, load the layout from a file calling a procedure similar to
    the following:



    In VB:


    Private Sub LoadLayout()
    Dim LayoutDir As String = GetLayoutDirectory() + "\ExplorerBarLayout.ebl"
    Dim LayoutStream As FileStream
    LayoutStream = New FileStream(LayoutDir, FileMode.Open)
    ExplorerBar1.LoadLayoutFile(LayoutStream)
    LayoutStream.Close()
    End Sub


    In C#:


    private void LoadLayout()
    {
    string layoutDir = GetLayoutDirectory() + @"\ExplorerBarLayout.ebl";
    FileStream layoutStream;
    layoutStream = new FileStream(layoutDir, FileMode.Open);
    explorerBar1.LoadLayoutFile(layoutStream);
    layoutStream.Close();
    }


    5) Add a button and change its Text property to "Save".

    6) In the Click event of the save button, save the layout from to file calling a procedure similar to
    the following:


    In VB:


    Private Sub SaveLayout()
    Dim LayoutDir As String = GetLayoutDirectory() + "\ExplorerBarLayout.ebl"
    Dim LayoutStream As FileStream
    LayoutStream = New FileStream(LayoutDir, FileMode.Create)
    ExplorernBar1.SaveLayoutFile(LayoutStream)
    LayoutStream.Close()
    End Sub


    In C#:


    private void SaveLayout()
    {
    string layoutDir = GetLayoutDirectory() + @"\ExplorerBarLayout.bbl";
    FileStream layoutStream;
    layoutStream = new FileStream(layoutDir, FileMode.Create);
    explorerBar1.SaveLayoutFile(layoutStream);
    layoutStream.Close();
    }


    Note: You can also save the current layout by calling the Update method of the Layout.


    In VB:


    If Not ExplorerBar1.CurrentLayout Is Nothing Then
    ExplorerBar1.CurrentLayout.Update()
    End If


    In C#:


    if(explorerBar1.CurrentLayout!=null)
    {
    explorerBar1.CurrentLayout.Update();
    }



    7) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using a ExplorerBarGroup as a Container Control [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to set an ExplorerBarGroup as a container control.

    The steps followed to create this project are:

    1) Create a new Visual Basic or C# project using "Windows Application" Template.

    2) Drag an ExplorerBar control from the toolbox into the Form designer.

    3) Right click in the ExplorerBar control and select "ExplorerBar Designer" menu. In the
    ExplorerBar dialog add a new group and set its Container property to true in the property
    window.

    4) In the Load event of the form add the TreeView control as follows:


    In C#


    private void Form1_Load(object sender, System.EventArgs e)
    {
    this.explorerBar1.Groups[0].ContainerControl.Controls.Add(this.treeView1);
    this.treeView1.Dock = DockStyle.Fill;
    }


    In VB


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
    MyBase.Load
    Me.ExplorerBar1.Groups(0).ContainerControl.Controls.Add(Me.TreeView1)
    Me.TreeView1.Dock = DockStyle.Fill
    End Sub


    Note: At design time you can just drag the TreeView control into the ExplorerBarGroup directly


    5) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Show ExplorerBar Groups in several columns [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to set ExplorerBar groups in several columns.


    The steps followed to create this project are:


    1) Create a new Visual Basic or C# project using "Windows Application" Template.



    2) Drag an ExplorerBar control from the toolbox into the Form designer.

    3) Select the ExplorerBar control and change the Columns property to 3 in the property
    window.

    4) Right click in the ExplorerBar control and select "ExplorerBar Designer" menu. Add new
    groups and items to the ExplorerBar control in the Designer.

    Note: You can specify the column span of each group with the ColumnSpan property of the
    ExplorerBarGroup.


    5) Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using GridEX in SelfReferencing HierarchicalMode [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use GridEX to display a self-referencing table in a tree fashion.



    1) Create a new Visual Basic or C# project using "Windows Application" Template.



    2) Add a new Data Source to the application:



    Click in the "Add New Data Source..." menu under "Data" and follow the wizard to add "Messages" table from GridEXTutorialsData.mdb database.



    In the tutorial we used Provider = "Microsoft Access Database File (OLE DB)" and Database file name = "C:\GridEXTutorialsData.mdb".



    3) Build the project to be able to see GridEXTutorialsDataDataSet and MessagesTableAdapter as components in the Toolbox.



    4) Drag from the tool box GridEXTutorialsDataDataSet component and MessagesTableAdapter component.



    5) Drag a GridEX control from the toolbox into the Form designer.



    6) Select GridEX control in the Form and set the following properties in the properties window:



    DataSource = GridEXTutorialsDataDataSet1

    DataMember = Messages




    7) Right click in the GridEX control and select "Retrieve Structure" menu to create the columns matching those found in the DataSource.



    8) Right click in the GridEX control and select "Designer" menu. In the Designer dialog, under RootTable node select Columns node and move the columns positions as you want using Move Up and Move Down toolbar buttons. In the sample, the following properties were changed in the columns:



    Column
    Property
    New Value



    MessageID
    Visible
    False



    ParentMessageID
    Visible
    False



    Subject
    ColumnType
    ImageAndText

    ImageIndex
    0*







    *To be able to set ImageIndex, an ImageList was added to the form and assigned as the ImageList property of the GridEX control



    ** Selectable property is set as False in all columns.





    9) In the designer, now select SelfReferencingSettings node under RootTable and click in the "SelfReferencing Wizard" button that appears at the right side. The settings we used in the wizard are:





    HierarchicalMode
    SelfReferencing
    To present Tree-like hierarchies in a GridEX control.



    ParentDataMember
    MessageID
    The field that identifies the parent column in the self-referencing relation.



    ChildDataMember
    ParentMessageID
    The field that identifies the child column in the self-referencing relation.



    ExpandColumn
    Subject
    The column in the table where the expand glyph will be displayed.







    10) In the Load event of the Form fill the "Messages" table in the dataset with the following code:



    In VB .Net



    MessagesTableAdapter1.Fill(GridEXTutorialsDataDataSet1.Messages)



    In C#.Net



    messagesTableAdapter1.Fill(gridEXTutorialsDataDataSet1.Messages);




    11) To create a new MessageDataRow in the application, MessageDialog form was added to the project. The form consists of 3 EditBox controls that let the user enter the Subject, the name of the user creating the message and a Message body. This form is called by the method CreateMessage in Form1 as follows:



    private void CreateMessage(object parentId,string subject)

    {

    MessageDialog message = new MessageDialog();

    message.Subject = subject;

    if (message.ShowDialog() == DialogResult.OK)

    {

    //Add a new message row to the dataset

    GridEXTutorialsDataDataSet.MessagesRow newMessage;



    newMessage = gridEXTutorialsDataDataSet1.Messages.NewMessagesRow();

    newMessage.Subject = message.Subject;

    if (message.From.Length == 0)

    {

    newMessage.From = "ANONIMOUS";

    }

    else

    {

    newMessage.From = message.From;

    }

    newMessage.Message = message.Message;

    newMessage.Date = DateTime.Now;

    if (parentId != null)

    {

    newMessage.ParentMessageID = (int)parentId;

    }

    //Add the row to the dataset and it will be displayed

    //automatically in the grid.

    gridEXTutorialsDataDataSet1.Messages.Rows.Add(newMessage);

    //Select the new row in grid

    gridEX1.MoveTo(gridEX1.GetRow(newMessage));

    gridEX1.Focus();
    }

    }





    12) Finally, add 3 buttons to the form:



    btnNewMessage (Text = "New Message...")



    In the Click event, a new message with no parent is created as follows:



    CreateMessage(null, "New Message");



    btnReplyMessage (Text = "Reply Message...")



    In the Click event, a message with the selected row id as parent is created as follows:





    if (gridEX1.CurrentRow != null &&

    gridEX1.CurrentRow.RowType == RowType.Record)

    {

    CreateMessage(gridEX1.GetValue("MessageID"), "RE: " + gridEX1.GetValue("Subject"));

    }

    else

    {

    MessageBox.Show("Select the message to reply." , "",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

    }



    btnDelete (Text = "Delete Message")



    In the Click event, the selected message is deleted as follows:



    if (gridEX1.CurrentRow != null &&

    gridEX1.CurrentRow.RowType == RowType.Record)

    {

    gridEX1.Delete();

    }

    else

    {

    MessageBox.Show("Select the message you want to delete", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

    }



    13) Other properties set in the GridEX control are:



    AllowEdit = False

    AllowDelete = True To be able to use GridEX.Delete method

    HideSelection = Highlight To see the selected row even when grid is not focused.

    14) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using GridEX Control in Unbound Mode [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use GridEX control in unbound mode using AddItem method to add rows to the control.



    Follow these steps to create a simple form using a GridEX control to display unbound items.



    1) Create a new Visual Basic or C# project using "Windows Application" Template.

    2) Open Form1 that was created when the project was created.

    3) Drop a GridEX control into Form1.

    4) Set BoundMode property in GridEX equal to BoundMode.Unbound

    5) Open GridEX Designer. Click in the "Create Root Table" button.

    6) Add columns to the RootTable.



    To create the columns, follow these steps:



    6.1 - In the GridEX Designer, select Columns collection below the RootTable node and click in the Add button.



    6.2 - Select "Unbound Column" and change the Key of the new column to "Name". Click Next, then Click Finish.



    6.3 - Click Add Button Again. In the "Add Column Wizard", Select "Unbound Column" and change the key of the new Column to "Date". Click Next.



    6.4 - Change EditType property to CalendarCombo. Click Finish.



    6.5 - Once the "Date" column is add, select the column in the designer and change the following properties:



    DataTypeCode = DateTime

    FormatString = d

    DefaultGroupInterval = Date





    7) Add a button to the form. Set its Text = "Add Item". In the click event of the button, use the following code:



    In VB .NET:





    In C# .NET:



    //Add a new row at the end of the list specifying its cell values.

    GridEXRow newRow = this.gridEX1.AddItem();

    //To edit values in cells of a row, call BeginEdit/EndEdit methods

    newRow.BeginEdit();

    newRow.Cells["Name"].Value = "InsertItem";

    newRow.Cells["Date"].Value = DateTime.Now;

    newRow.EndEdit();

    //Move to the new item

    this.gridEX1.MoveTo(newRow);



    8) Add another button. Set its Text = "Insert Item". In the click event of the button, use the following code:



    In VB .NET:





    In C# .NET:



    //Insert the item at the beginning of the list.

    GridEXRow newRow = this.gridEX1.AddItem(0);

    //To edit values in cells of a row, call BeginEdit/EndEdit methods

    newRow.BeginEdit();

    newRow.Cells["Name"].Value = "InsertItem";

    newRow.Cells["Date"].Value = DateTime.Now;

    newRow.EndEdit();

    //Move to the new item

    gridEX1.MoveTo(newRow);



    9) Add another button. Set its Text = "Remove Selected Item". In the click event of the button, use the following code:



    In VB .NET:





    In C# .NET:



    //Get current row

    GridEXRow item = gridEX1.CurrentRow;

    If (item != null && item.RowType == RowType.Record)

    {
    //Delete the row.

    item.Delete();
    }

    else

    {
    MessageBox.Show("Select an item to delete.");
    }



    10) Add another button. Set its Text = "Clear Items". In the click event of the button, use the following code:



    In VB .NET:





    In C# .NET:



    //Clear all items in GridEX

    this.gridEX1.ClearItems();



    11) In the Load event of the form, add some rows to the grid.



    In VB .NET:





    In C# .NET:



    this.gridEX1.AddItem("Item 1", DateTime.Now);

    this.gridEX1.AddItem("Item 2", DateTime.Now);

    this.gridEX1.AddItem("Item 3", DateTime.Now);

    this.gridEX1.AddItem("Item 4", DateTime.Now);

    this.gridEX1.AddItem("Item 5", DateTime.Now);

    this.gridEX1.Row = 0;



    12) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using GridEX Control as a Checked List [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use GridEX control as a checked list control with a column acting as selector and the use of the GetCheckedRows method to retrieve an array containing the GridEXRow objects that are checked.



    Follow these steps to create a simple form using a GridEX control as a checked list.



    1) Create a new Visual Basic or C# project using "Windows Application" Template.

    2) Drop a GridEX control into Form1.

    3) In the GridEX Designer dialog, select the GridEX control node and click in the "Create Root Table" button.

    4) Select the Columns node under RootTable node and start the columns the control will present. In this tutorial we created 4 columns. The columns we created and the properties are listed below:



    4.1) From:



    Add Column Wizard:



    Step 1:

    "Selector Column"

    UseHeaderSelector = True



    4.2) Icon:



    Add Column Wizard:



    Step 1:

    "Unbound Column"

    BoundMode: UnboundFetch

    Key = "Icon"



    Step 2:

    Caption = ""

    ColumnType = Image

    EditType = NoEdit



    After finishing the wizard, set these properties:



    AllowSize = False

    ImageIndex = 0

    Selectable = False

    Width = 20



    4.3) From:



    Add Column Wizard:



    Step 1:

    "Bound Column"

    DataMember = "From"



    Step 2:

    Caption = "From"

    ColumnType = Text

    EditType = NoEdit



    After finishing the wizard, set these properties:

    Selectable = False


    4.4) Subject:

    Add Column Wizard:



    Step 1:

    "Bound Column"

    DataMember = "Subject"



    Step 2:

    Caption = "Subject"

    ColumnType = Text

    EditType = NoEdit



    After finishing the wizard, set these properties:

    Selectable = False



    4.5) Date:

    Add Column Wizard:



    Step 1:

    "Bound Column"

    DataMember = "Date"



    Step 2:

    Caption = "Date"

    ColumnType = Text

    EditType = NoEdit



    After finishing the wizard, set these properties:

    Selectable = False







    5) In the Load event of the Form, Call the BindGridEXControl procedure that creates the dataset and binds the control to it:



    In VB .Net:



    Private Sub BindGridEXControl()

    Dim ds As New DataSet()

    Dim table As New DataTable("Messages")

    table.Columns.Add(New DataColumn("From", Type.GetType("System.String")))

    table.Columns.Add(New DataColumn("Subject", Type.GetType("System.String")))

    table.Columns.Add(New DataColumn("Date", Type.GetType("System.DateTime")))

    ds.Tables.Add(table)

    table.Rows.Add(New Object() {"john@mail.com", "Greetings", New DateTime(2002, 2, 5)})

    table.Rows.Add(New Object() {"jenny@mail.com", "Invitation", New DateTime(2002, 2, 7)})

    table.Rows.Add(New Object() {"chris@mail.com", "A question", New DateTime(2002, 2, 10)})

    table.Rows.Add(New Object() {"ana@mail.com", "How are you?", New DateTime(2002, 2, 12)})

    table.Rows.Add(New Object() {"katherine@mail.com", "Greetings", New DateTime(2002, 2, 14)})

    table.Rows.Add(New Object() {"bill@mail.com", "Hi", New DateTime(2002, 2, 18)})

    table.Rows.Add(New Object() {"ronald@mail.com", "No Subject", New DateTime(2002, 2, 20)})

    Me.GridEX1.SetDataBinding(ds, "Messages")

    End Sub



    In C# .Net:



    private void BindGridEXControl()
    {
    DataSet ds = new DataSet();

    DataTable table = new DataTable("Messages");

    table.Columns.Add(new DataColumn("From", typeof(string)));

    table.Columns.Add(new DataColumn("Subject", typeof(string)));

    table.Columns.Add(new DataColumn("Date", typeof(DateTime)));

    ds.Tables.Add(table);

    table.Rows.Add(new Object[] {"john@mail.com", Greetings", new DateTime(2002, 2, 5)});

    table.Rows.Add(new Object[] {"jenny@mail.com", "Invitation", new DateTime(2002, 2, 7)});

    table.Rows.Add(new Object[] {"chris@mail.com", "A question", new DateTime(2002, 2, 10)});

    table.Rows.Add(new Object[] {"ana@mail.com", "How are you?", new DateTime(2002, 2, 12)});

    table.Rows.Add(new Object[] {"katherine@mail.com", "Greetings", new DateTime(2002, 2, 14)});

    table.Rows.Add(new Object[] {"bill@mail.com", "Hi", new DateTime(2002, 2, 18)});

    table.Rows.Add(new Object[] {"ronald@mail.com", "No Subject", new DateTime(2002, 2, 20)});

    this.GridEX1.SetDataBinding(ds, "Messages");

    }





    6) Add a button to the form and set its Text property to "Delete". In the Click event of the delete button, get an array containing the checked rows and delete them from its table.



    In VB .Net:





    Dim checkedRows() As Janus.Windows.GridEX.GridEXRow

    'get an array with all the rows that the user checked.

    checkedRows = Me.GridEX1.GetCheckedRows()

    'if the user didn't check any row, you will get an empty array

    If checkedRows.Length = 0 Then

    MessageBox.Show("Select at least 1 message to be deleted.")

    Else

    Dim message As String

    message = String.Format("You are about to delete {0} message(s)." _

    & vbCrLf & "Do you want to continue?", checkedRows.Length)

    If MessageBox.Show(message, "Janus Tutorial", MessageBoxButtons.YesNo) = DialogResult.Yes Then

    Dim row As Janus.Windows.GridEX.GridEXRow

    For Each row In checkedRows
    CType(row.DataRow, DataRowView).Delete()
    Next

    End If

    End If



    In C# .Net:



    Janus.Windows.GridEX.GridEXRow[] checkedRows;

    //get an array with all the rows that the user checked.

    checkedRows = this.GridEX1.GetCheckedRows();

    //if the user didn't check any row, you will get an empty array

    if(checkedRows.Length==0)

    {
    MessageBox.Show("Select at least 1 message to be deleted.");
    }

    else

    {
    string message;

    message = String.Format("You are about to delete {0} message(s)." +

    "\n\rDo you want to continue?", checkedRows.Length);

    if(MessageBox.Show(message, "Janus Tutorial", MessageBoxButtons.YesNo) == DialogResult.Yes)

    {

    foreach(Janus.Windows.GridEX.GridEXRow row in checkedRows)

    {

    ((DataRowView)row.DataRow).Delete();

    }

    }

    }



    7) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using ColumnSets [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use column sets to have more that one line of columns to present a record.



    1 - Create a new Visual Basic or C# project using "Windows Application" Template



    2 - Add a GridEX control to Form1.



    3 - Add Employees table from JSNorthwind database as a Data Source for the application. After adding the table, build the application to be able to see EmployeesTableAdapter and JSNorthwindDataSet components in the tool box.



    4 - From the "Data Sources" window in the Application, drag Employees table and drop it into the new GridEX control. JSNorthwindDataSet, EmployeesTableAdapter and EmployeesBindingSource components will be created.



    5 - In the Designer window of the GridEX control click on the "Retrieve Structure" button to let GridEX control create the root table and the columns matching those found in the data source.



    6 - Select the ColumnSets node under the RootTable node in the designer. Once you have selected the ColumnSets collection, click in the "ColumnSet Designer.." button that appears at the right of the designer.



    9 - The first thing you need to do when designing a column set layout is to define how many lines of columns a record will have. To do this, set the ColumnSetRowCount property in the table. In this tutorial, the ColumnSetRowCount property was set to 3.



    10 - In the ColumnSets Designer, add a ColumnSet clicking in the "Add ColumnSet" button. Once you click in the button an empty column set will appear in the "ColumnSet Layout" panel. In the ColumnSet, set the number of columns you want to have in it.



    11 - From the list of columns in the left side of the designer, drag any column and drop it into the one of the empty slots of the ColumnSet. If you want a column to span 2 or more columns, set the ColSpan property of the column. If you want to a column to span 2 or more rows, set the RowSpan property of the column. ColSpan and RowSpan properties can be set only when a column has been added to a ColumnSet.





    12 - Keep creating ColumnSets and filling them with columns by dragging a column from the list and dropping it into a columnset cell until you have defined the ColumnSet layout you want.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using Unbound Columns [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show how to use unbound columns in a bound GridEX control.



    Follow these steps to create a simple form using a GridEX control to display records from a table in a database with one unbound column whose values are set in the LoadingRow event.



    1 - Create a new Visual Basic or C# project using "Windows Application" Template



    2 - Add "Order Details" Table from JSNorthwind database as a Data Source for the application. After adding the table, build the application to be able to see Order_DetailsTableAdapter and JSNorthwindDataSet components in the tool box.



    3 - Add a GridEX control to Form1.



    4 - From the "Data Sources" window in the Application, drag Order_Details table and drop it into the new GridEX control. JSNorthwindDataSet, Order_DetailsTableAdapter and Orders_DetailsBindingSource components will be created.



    5 - In the Designer window of the GridEX control click on the "Retrieve Structure" button to let GridEX control create the root table and the columns matching those found in the data source.



    6 - Once the base structure is created, modify the layout as you want, changing the column positions, column widths.



    7 - To create an unbound column, follow these steps:



    8.1 - In the GridEX Designer, select Columns collection below the RootTable node and click in the Add button.



    8.2 - Select "Unbound Column" and change the Key of the new column to "Total". Click Next.



    8.3 - Select NoEdit in the EditType Combo. Click Finish.



    8.4 - Finally, in the FormatString property of the column, set "c" to see the values of the columns formatted as currency values.



    9 - The cells under an unbound column are empty by default. To set the value of a cell that belongs to an unbound column, the developer must handle the LoadingRow event and set the value in the GridEXCell object like it is done in the following code:



    In VB.Net



    If e.Row.RowType = RowType.Record Then

    e.Row.Cells("Total").Value = totalValue

    End If



    In C#.Net



    if(e.Row.RowType==RowType.Record)

    {

    e.Row.Cells["Total"].Value = totalValue;

    }





    10 - Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using Image Columns [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use image columns in a bound GridEX control.



    In this tutorial, there are three column showing images. The first image column shows a default image for every cell in the column. In the second image column, the image is set in code depending on values of other cells in the same row and in the third image column the image displayed in the cell is set in a ValueList so it is dependant on the value of the cell.



    1 - Create a new Visual Basic or C# project using "Windows Application" Template



    2 - Add Products and Categories Tables from JSNorthwind database as a Data Source for the application. After adding the Tables, build the application to be able to see ProductsTableAdapter and CategoriesTableAdapter components in the tool box.



    3 - Add a GridEX control to Form1.



    4 - From the "Data Sources" window in the Application, drag Products table and drop it into the new GridEX control. JSNorthwindDataSet, ProductsTableAdapter and ProducctsBindingSource components will be created.



    5 - In the Designer window of the GridEX control click on the "Retrieve Structure" button to let GridEX control create the root table and the columns matching those found in the data source.



    6 - Once the base structure is created, modify the layout as you want, changing the column positions, column widths.



    7 - Add an ImageList component to the form and assign it to the GridEX control setting its ExternalImageList property as the ImageList you added to the form. Add the Images you are going to use in the GridEX control. In this tutorial, we added 8 images corresponding to each product category, one image that represents the product and two other images: one to be displayed in products that are on sale and one to displayed in products that are discontinued.



    8 - To create a simple image column follow these steps:



    8.1 - In the GridEX Designer, select Columns collection below the RootTable node and click in the Add button.



    8.2 - Select "Unbound Column" and change the Key of the new column to "Icon". Click Next.



    8.3 - Clear the default Caption in the wizard and select Image in the ColumnType combo. Click Finish.



    8.4 - Finally, in the ImageIndex or ImageKey property of the column, select the image you want to show in all the cells below that column.



    9 - To create an image column that displays an image depending on the value of other cells in the row follow these steps:



    9.1 - In the GridEX Designer, select Columns collection below the RootTable node and click in the Add button.



    9.2 - Select "Unbound Column" and Change the Key of the new column to "StatusIcon". Click Next.



    9.3 -Clear the default Caption in the wizard and set Image in the ColumnType combo. Click Finish.



    9.4 - Finally, in the FormattingRow event of the control, write the code that sets the image index for each cell below that column:



    In VB .Net:

    Private Sub GridEX1_FormattingRow(ByVal sender As System.Object, _

    ByVal e As RowLoadEventArgs) Handles GridEX1.FormattingRow

    If e.Row.RowType = RowType.Record Then

    If CType(e.Row.Cells("Discontinued").Value, Boolean) Then

    e.Row.Cells("StatusIcon").ImageKey = "discontinued"

    ElseIf CType(e.Row.Cells("OnSale").Value, Boolean) Then

    e.Row.Cells("StatusIcon").ImageKey = "onsale"

    End If

    End If

    End Sub



    In C# .Net:



    private void GridEX1_FormattingRow(object sender, RowLoadEventArgs e)

    {

    if (e.Row.RowType == RowType.Record)

    {

    if ((bool)e.Row.Cells["Discontinued"].Value)

    {

    e.Row.Cells["StatusIcon"].ImageKey = "discontinued";

    }

    else if ((bool)e.Row.Cells["OnSale"].Value)

    {

    e.Row.Cells["StatusIcon"].ImageKey = "onsale";

    }

    }

    }

    10 - To create an image column that displays an image assigned in a ValueList, follow these steps:



    10.1 - In the GridEX Designer, select Columns collection below the RootTable node and, from the list of columns select CategoryID column.



    10.2 -Set the ColumnType property of the column to ColumnType.ImageAndText and its EditType property to EditType.DropDownList



    10.3 - Finally, in the Load event of the form, fill the ValueList with the categories available and assign one image to each item in the value list:



    In VB .Net:



    Dim categories As GridEXColumn

    categories = GridEX1.RootTable.Columns("CategoryID")

    categories.HasValueList = True

    categories.ColumnType = ColumnType.ImageAndText

    categories.EditType = EditType.DropDownList

    Dim ValueList As GridEXValueListItemCollection

    ValueList = categories.ValueList

    Dim row As JSNorthWindDataSet.CategoriesRow

    For Each row In JSNorthWindDataSet.Categories.Rows

    Dim item As GridEXValueListItem

    item = New GridEXValueListItem(row.CategoryID, _

    row.CategoryName)

    'set image Key for items

    item.ImageKey = "Cat(" & row.CategoryID & ")"

    ValueList.Add(item)

    Next

    In C# .Net:



    GridEXColumn categories = this.gridEX1.RootTable.Columns["CategoryID"];

    //To be able to get the ValueList from a column, its

    //HasValueList property must be true

    categories.HasValueList = true;

    categories.ColumnType = ColumnType.ImageAndText;

    categories.EditType = EditType.DropDownList;

    GridEXValueListItemCollection ValueList = categories.ValueList;



    //Categories table in the dataset was added as

    //the products table was added before

    foreach(NorthWind.CategoriesRow row in this.northWind1.Categories.Rows)

    {

    GridEXValueListItem item;

    item=new GridEXValueListItem(row.CategoryID,row.CategoryName);

    if(row.CategoryID<=8) { //set image index for items 1 - 8 //images start from 0 in the image list item.ImageIndex = row.CategoryID - 1; } ValueList.Add(item); }


    15 - Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Binding GridEX Control to an IList [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to bind GridEX control to a collection in your project that supports IList interface.



    Note: When binding to an IList, a data bound control can not add records to the list. To let the users add records in a GridEX control bound to a collection you should implement the IBindingList interface in your collection or handle the GetNewRow event to do create the new object in code.



    Follow these steps to create a simple form using a GridEX control to display an IList.



    1) Create a new Visual Basic or C# project using "Windows Application" Template.

    2) Add a new class into the project and name it Person.

    3) Add the following properties to the Person class: Title, Name, LastName and Suffix.

    4) To create the collection or person objects, add a new class to the project and name it PersonCollection.

    5) Inherit the PersonCollection class from System.Collections.CollectionBase class. CollectionBase class implements IList interface.

    6) Create the indexer method as well as the Add and Remove methods in the PersonCollection class.

    7) Open Form1 that was created when the project was created.

    8) Drop a GridEX control into Form1.

    9) Add a button, set the Text property of this button to "Fill Collection"

    10) In the Click event of Button1 create a new instance of the PersonCollection class add a few Person objects to the collection and bind it to the GridEX control as follows:



    In VB .NET:



    'Creating the collection

    people = New PersonCollection()

    people.Add(New Person("Mr.", "John", "Smith", "Sr."))

    people.Add(New Person("Mrs.", "Mary", "Jones", ""))

    people.Add(New Person("Miss", "Sally", "Porter", ""))

    people.Add(New Person("Mr.", "Joseph", "Gold", "Jr."))

    people.Add(New Person("Dr.", "Ian", "Goldsmith", ""))



    'Binding GridEX to the people collection

    gridEX1.SetDataBinding(people, "")

    'Forcing GridEX control to generate the columns needed

    'to display all the properties in the Person class.

    gridEX1.RetrieveStructure()



    In C# .NET:



    //Creating the collection

    people = new PersonCollection();

    people.Add(new Person("Mr.","John","Smith","Sr."));

    people.Add(new Person("Mrs.","Mary","Jones",""));

    people.Add(new Person("Miss","Sally","Porter",""));

    people.Add(new Person("Mr.","Joseph","Gold","Jr."));

    people.Add(new Person("Dr.","Ian","Goldsmith",""));



    //Binding GridEX to the people collection

    gridEX1.SetDataBinding(people,"");

    //Forcing GridEX control to generate the columns needed

    //to display all the properties in the Person class.

    gridEX1.RetrieveStructure();



    11) To allow add and remove rows from the collection set the following properties:



    AllowAddNew = Janus.Windows.GridEX.TriState.True

    AllowDelete = Janus.Windows.GridEX.TriState.True



    12) Since IList doesn't implement an AddNew method to allow the CurrencyManager to add new records you will get an exception when the user tries to add a record in the GridEX control. If you know how to create a new object of the same type the list holds, use the GetNewRow event. This event is raised to let you create a new instance of an object presented by the GridEX control.





    In VB .NET:



    Private Sub gridEX1_GetNewRow(ByVal sender As Object,ByVal e As GetNewRowEventArgs) Handles gridEX1.GetNewRow

    e.NewRow = New Person()

    End Sub



    In C# .NET:



    private void gridEX1_GetNewRow(object sender, GetNewRowEventArgs e)

    {

    e.NewRow = new Person();

    }



    13) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using Custom Edit Events [Janus GridEX WinForms Control v3.5 for .NET] Steps to reproduce this sample:



    1) Create a new "Windows Application" Project.



    2) Add Customers Table from JSNorthwind database as a Data Source for the application.



    3) Add GridEX Control to a tab in the Toolbox window by right clicking in the Toolbox window and choosing "Customize Toolbox..." menu. When the dialog appears, select ".Net Framework Components" tab, check "GridEX" control in the list and click OK.
    Note: If GridEX control doesn't appear as an option in the list, click the Browse button and open Janus.Windows.GridEX.dll.



    4) Drag a GridEX control from the toolbox into the Form designer.



    5) From the "Data Sources" window in the Application, drag Customers and drop it into the new GridEX control. JSNorthwindDataSet, CustomersTableAdapter and CustomersBindingSource components will be created.



    5) Right click in the GridEX control and select "Retrieve Structure" menu. This action will force the control to read the DataSource structure and create the tables and columns needed to show all the fields in the tables.



    6) Right click in the GridEX control again and select "GridEX Designer" menu. In the GridEX designer dialog, select "Columns" under GridEX/RootTable node.



    7) In the right pane, select "CustomerID" column and change the EditType property to Custom. Setting this property, you will be able to get the InitCustomEdit event every time the user tries to edit a cell in this column.



    8) Drop a TextBox control into the Form and change its name to txtCustom. This text box will be the one used as the edit window in the CustomerID column.




    9) In the InitCustomEdit event of the GridEX control, set the Text property of the TextBox acting as the custom edit control and set the EditControl property of the InitCustomEditEventArgs parameter to the txtCustom control.



    In VB .NET



    'For the sample, we will use BackColor Yellow in the TextBox

    'if the cell is in a new row

    If e.Row.RowType = RowType.NewRecord Then

    txtCustom.BackColor = Color.Yellow

    Else

    txtCustom.BackColor = e.FormatStyle.BackColor

    End If



    'When the user start edition by pressing a key,

    'the EditChar property holds the char that

    'started the edition. If edition was started

    'because the user clicked in the cell the

    'EditChar returns (char)0

    If Char.IsLetterOrDigit(e.EditChar) Then

    txtCustom.Text = e.EditChar.ToString()

    txtCustom.SelectionStart = txtCustom.Text.Length

    Else

    If e.Value Is Nothing Then

    txtCustom.Text = ""

    Else

    txtCustom.Text = e.Value.ToString()

    End If

    txtCustom.SelectionLength = txtCustom.Text.Length

    End If

    'Set the EditControl property to let the GridEX control

    'know which control to position in the cell.

    e.EditControl = txtCustom



    In C# .NET



    //For the sample, we will allow to edit

    //the CustomerID field only in new rows.

    //So, we set the ReadOnly property to false

    //if rows with RowType set to Record.

    if(e.Row.RowType==RowType.NewRecord)

    {

    txtCustom.ReadOnly=false;

    }

    else

    {

    txtCustom.ReadOnly = true;

    }

    //When the user start edition by pressing a key,

    //the EditChar property holds the char that started

    //the edition. If edition was started because the

    //user clicked in the cell the EditChar

    //returns (char)0

    if(e.EditChar!=(char)0 && !txtCustom.ReadOnly)

    {

    txtCustom.Text = e.EditChar.ToString();

    txtCustom.SelectionStart = txtCustom.Text.Length;

    }

    else

    {

    if(e.Value==null)

    {

    txtCustom.Text = "";

    }

    else

    {

    txtCustom.Text = e.Value.ToString();

    }

    txtCustom.SelectionLength = txtCustom.Text.Length;

    }

    //Set the EditControl property to let the GridEX control

    //know which control to position in the cell.

    e.EditControl = txtCustom;



    10) In the EndCustomEdit event of the GridEX control, compare value of the value in the TextBox to the original value in the cell. If the value has changed, set the Value property of the EndCustomEditEventArgs parameter to the new value and set the DataChanged property to true to inform the GridEX control that the cell must be updated in the data source.



    In VB .NET

    If Not e.CancelUpdate Then

    If e.Value <> txtCustom.Text Then

    e.Value = txtCustom.Text

    End If

    End If



    In C# .NET



    //Compare the original value with

    //the value in the control.

    if(txtCustom.Text.CompareTo(e.Value)!=0)

    {
    //If the value is different,

    //set the DataChanged property to true

    //to indicate the control that it has

    //to update the cell value.

    e.DataChanged = true;

    e.Value = txtCustom.Text;
    }
    11) Press F5 and run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more
  • Using a layout file to preserve user changes [Janus GridEX WinForms Control v3.5 for .NET] This tutorial is intended to show you how to use a layout file to preserve GridEX control settings. Using a layout file you could be able to preserve the changes to the layout made by the user.



    The Layout file used in this tutorial was saved with the GridEX designer using the multiple layouts defined in tutorial 13.



    Follow these steps to use a layout file at run time:



    1 - Define the layout at design time and then save it clicking in the "Save Layout File" button that is found in the "Layout Manager" tab of the GridEX control designer.



    2 - (Optional) Clear all the settings of the GridEX control at run time clicking in the menu "Reset Defaults" that appears when you right click a GridEX control.



    3 - In the Load event of the form, load the layout from a file calling a procedure similar to the following:



    In VB:



    Private Sub LoadLayout()

    Dim LayoutDir As String = GetLayoutDirectory() + "\GridEXLayout.gxl"

    Dim LayoutStream As FileStream

    LayoutStream = New FileStream(LayoutDir, FileMode.Open)

    GridEX1.LoadLayoutFile(LayoutStream)

    LayoutStream.Close()

    End Sub



    In C#:



    private void LoadLayout()

    {

    string layoutDir = GetLayoutDirectory() + @"\GridEXLayout.gxl";

    if (FileExists(layoutDir))

    {

    FileStream layoutStream;

    layoutStream = new FileStream(layoutDir, FileMode.Open);

    GridEX1.LoadLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }



    4 - In the CurrentLayoutChanged event, bound the GridEX control to its data source and fill the data source as follows:



    In VB:



    Private Sub GridEX1_CurrentLayoutChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridEX1.CurrentLayoutChanged

    'clear the DataTable used by the previous layout

    JsNorthWindDataSet1.Clear()

    'when layouts are persisted into a file,

    'the DataSource and DataMember properties are

    'not persisted so you must reset them at run time

    'instead of resetting the DataSource and DataMember

    'properties when the layout is made, this could be done

    'in all the layouts at once in the LayoutLoad event

    If Not GridEX1.CurrentLayout Is Nothing Then

    Select Case GridEX1.CurrentLayout.Key

    Case "Customers"

    CustomersTableAdapter1.Fill(JsNorthWindDataSet1.Customers)

    GridEX1.SetDataBinding(JsNorthWindDataSet1, "Customers")

    Case "Products"

    ProductsTableAdapter1.Fill(JsNorthWindDataSet1.Products)

    GridEX1.SetDataBinding(JsNorthWindDataSet1, "Products")

    Case "Suppliers"

    SuppliersTableAdapter1.Fill(JsNorthWindDataSet1.Suppliers)

    GridEX1.SetDataBinding(JsNorthWindDataSet1, "Suppliers")

    End Select

    End If



    End Sub



    In C#:



    private void GridEX1_CurrentLayoutChanged(object sender, EventArgs e)

    {

    //clear the DataTable used by the previous layout

    jsNorthWindDataSet1.Clear();



    //When layouts are persisted into a file,

    //the DataSource and DataMember properties are

    //not persisted so you must reset them at run time

    //instead of resetting the DataSource and DataMember

    //properties when the layout is made, this could be done

    //in all the layouts at once in the LayoutLoad event

    if (GridEX1.CurrentLayout != null)

    {

    switch (GridEX1.CurrentLayout.Key)

    {

    case "Customers":

    customersTableAdapter1.Fill(jsNorthWindDataSet1.Customers);

    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Customers");

    break;

    case "Products":

    productsTableAdapter1.Fill(jsNorthWindDataSet1.Products);

    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Products");

    break;

    case "Suppliers":

    suppliersTableAdapter1.Fill(jsNorthWindDataSet1.Suppliers);

    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Suppliers");

    break;

    }

    }

    }



    5- (Optional) To preserve user changes to the layout, update each layout before it is changed in the CurrentLayoutChanging event.



    In VB:



    Private Sub GridEX1_CurrentLayoutChanging(ByVal sender As Object, _

    ByVal e As System.ComponentModel.CancelEventArgs) Handles _

    GridEX1.CurrentLayoutChanging

    'to persist user changes in the current layout,

    'call the Update method explicitly before changing the layout

    If Not GridEX1.CurrentLayout Is Nothing Then

    GridEX1.CurrentLayout.Update()

    End If

    End Sub



    In C#:



    private void gridEX1_CurrentLayoutChanging(object sender, System.ComponentModel.CancelEventArgs e)

    {

    //to persist user changes in the current layout,

    //call the Update method explicitly before changing the layout

    if(gridEX1.CurrentLayout!=null)

    {

    gridEX1.CurrentLayout.Update();

    }

    }



    6 - In the Closing event of the form, save the layout file again to be able to preserve the changes the user did (like grouping, sorting, columns size and position etc).



    In VB:



    Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)

    Dim Result As DialogResult

    Dim LayoutDir As String

    Dim LayoutStream As FileStream





    Result = MessageBox.Show("Do you want to preserve the changes in the _

    GridEX control layout?", "Preserve changes", _

    MessageBoxButtons.YesNoCancel, _

    MessageBoxIcon.Question)

    If Result = DialogResult.Cancel Then

    e.Cancel = True

    ElseIf Result = DialogResult.Yes Then

    LayoutDir = GetLayoutDirectory() + "\GridEXLayout.gxl"

    LayoutStream = New FileStream(LayoutDir, FileMode.Create)

    GridEX1.SaveLayoutFile(LayoutStream)

    LayoutStream.Close()

    End If

    End Sub



    In C #:



    protected override void OnClosing(CancelEventArgs e)

    {

    base.OnClosing(e);

    DialogResult result;

    string layoutDir;

    FileStream layoutStream;



    result = MessageBox.Show("Do you want to preserve the changes in " +

    "the GridEX control layout?", "Preserve changes",

    MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

    if (result == System.Windows.Forms.DialogResult.Cancel)

    {

    e.Cancel = true;

    }

    else if (result == System.Windows.Forms.DialogResult.Yes)

    {

    DirectoryInfo dInfo;

    dInfo = new DirectoryInfo(Application.ExecutablePath).Parent;

    dInfo = new DirectoryInfo(dInfo.FullName + @"\LayoutData");

    if (!dInfo.Exists) dInfo.Create();

    layoutDir = dInfo.FullName + @"\GridEXLayout.gxl";

    layoutStream = new FileStream(layoutDir, FileMode.Create);

    GridEX1.SaveLayoutFile(layoutStream);

    layoutStream.Close();

    }

    }



    7 - Run the project.

    Source Of Information : Janus v3.5 Help Files for VS 2008

    more