Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Janus UI Multicolumn combo question

Options
  • 17-12-2004 1:33pm
    #1
    Registered Users Posts: 2,758 ✭✭✭


    Hello boardsters,

    I'm trying to move one of my projects from using bog standard UI MS controls to using Janus controls.

    The problem is that when i was developing the project I used collections instead of using Data adaters and datasets (would be making life a whole lot easier right now).

    So i'm wondering is it possible to set the datasource of the multicolumn combo to be a collection of objects. As i understand it a datasource can usually be anything that supports an IType list and my collection of (sites in this case) is a declared as:
    public class Sites : System.Collections.CollectionBase

    Would it be easier to go back and move my collections over to using data adapters and just generating a nice easy dataset? To do this might take about a week of deleopment and maybe longer testing and debugging.

    <edit>
    What i've tried so far is....
    multiColumnCombo1.DataSource = _sites;
    or
    multiColumnCombo1.SetDataBinding(_sites ,"" );
    
    I've al;so tried searching the Janus formun but to not avail...

    _sites is the collection of site objects.
    </edit>


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Peace wrote:
    So i'm wondering is it possible to set the datasource of the multicolumn combo to be a collection of objects.
    I haven't used multicolumnCombo objects from Janus, but my GridEx and ValueList components (from Janus) are all working fine against collections, so I'd be surprised if it was a problem.
    As i understand it a datasource can usually be anything that supports an IType list
    You mean anything that supports the IList interface, I assume, but yeah.
    Would it be easier to go back and move my collections over to using data adapters and just generating a nice easy dataset? To do this might take about a week of deleopment and maybe longer testing and debugging.
    You could simply add a "GenerateDataSet" method to your Sites class, and then bind to mySitesObject.GenerateDataSet() ???

    But it still shouldn't be necessary.....
    What i've tried so far is....
    multiColumnCombo1.DataSource = _sites;
    or
    multiColumnCombo1.SetDataBinding(_sites ,"" );
    
    The latter of these should set the DataBinding up ok, but you also have to map the relevant fields....which you do by using the built-in "designer" where you tell it you don't have the data-source at designtime, but here are the columns, their datatypes, and the names of what they are to be bound to. These names should be the names of the properties you want to display.

    jc


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Bonkey covered better than I did. Question though - I've never bound to a collection - Do you not have to specify a DataMember for the multicolumn combo?


    From the Janus documentation (yes its there in Visual Studio Help)
    public void SetDataBinding( 
       object dataSource,
       string dataMember
    );
    

    From what I can see you're only specifying a dataSource.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Phil...

    when binding to a collection, its always SetDataBinding(myCollection, "");

    I dunno why they didn't just supply two SetDataBinding methods with appropriate signatures, but as it is.....the empty string is correct.

    From memory, the dataMember is required only when you when you have an item like a DataSet which can contain multiple, bindable, sources.


  • Registered Users Posts: 2,758 ✭✭✭Peace


    I used that method but it didn't display anything in the drop down.

    Usually what i do the retrieve an item of the collection is mycollection.item(index)

    Is this the same as youself bonkey?


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Umm...no...but that looks like VB.Net syntax, while I'd program in C#, where it would be :

    something = myCollection[index];

    Tell ya what...isn't the control mostly defined through a block of XML saved as one of its properties, or is that just the Janus GridEx control? I'm it is, and if you paste that in here as it is for your control, I'll have a look at it and tell you if I can spot anything wrong in it, which would suggest that something is wrong in your definition.

    After that, the code should basically be databinding using :

    multiColumnCombo1.SetDataBinding(_sites ,"" );

    and then it should be populated...

    jc


  • Advertisement
  • Registered Users Posts: 2,758 ✭✭✭Peace


    bonkey wrote:
    Umm...no...but that looks like VB.Net syntax, while I'd program in C#, where it would be :

    something = myCollection[index];


    jc

    No no, i code C# also!

    public Site Item(int index)
    		{
    			return (Site)this.List[index];
    		}
    //More code forwhatever
    
    MessageBox.Show(_sites.Item(0).SiteID);
    

    Maybe its the way the collections are written. I learned it from another guy and basically just reused his code over and over for all the collections i use.

    I think I will be rewriting the project to ditch the collections anyway...


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Peace wrote:
    Maybe its the way the collections are written. I learned it from another guy and basically just reused his code over and over for all the collections i use.

    Just on this....here's the code I use for collections, in case you're interested Obviously, in 2.0 with the introduction of generics, this will be obsolete, but for now its quick n easy:
    using System;
    using System.Collections;
    
    namespace bonkey {
      /// <summary>
      /// Summary description for Widgets.
      /// </summary>
      public class Widgets : CollectionBase {
    
        #region Typed List methods    
        public int Add(Widget value) {
          return base.List.Add(value as object);
        }
    
        public void Remove(Widget value) {
          base.List.Remove(value as object);
        }
    
        public void Insert(int index, Widget value) {
          base.List.Insert(index, value as object);
        }
    
        public bool Contains(Widget value) {
          return base.List.Contains(value as object);
        }
    
        public Widget this[int index] {
          get { return (base.List[index] as Widget); }
        }
        #endregion
    
      }
    }
    

    This gives me a type-safe collection of Widgets, supporting the *basic* methods. The last one - this[int index] - is the one which makes the collection useable with the "proper" syntax.

    If I want other methods (IndexOf, for example) to also be typesafe, I just override them too.

    If I then had to work with a DataTable, I'd add a method to this collection called GetDataTable which did something like :
    [i]
    if (dataTable not previously generated) {
      generate dataTable structure
    }
    
    clear DataTable;
    populate dataTable from collection;
    
    return dataTable;
    [/i]
    

    jc


Advertisement