2005 .item() & .Select() replacements?

In 2003 I could set, for instance, the datagrid.item() and datagrid.select() to select a row after filtering the dataview results. These aren't available in 2005, how can this now be achieved

Answer this question

2005 .item() & .Select() replacements?

  • bubu

    And when you cast it to a DataGridView:


    // Create a DataGridView reference.
    DataGridView view = (DataGridView)dg1;

    - or -

    // Cast it and use it directly.
    ((DataGridView)db1).Item;




  • John E Katich

    Thank you very much Karen with solving this issue!


  • gssi

    not really a whole lot of code to show. I drew a datagridview on a windows form.

    The code generated by VS is:

    this.dg1 = new System.Windows.Forms.DataGridView();

    ((System.ComponentModel.ISupportInitialize)(this.dg1)).BeginInit();

    in form1 load event I try to enter:

    dg1.Item but "Item" doesn't show up and it gives the error I posted previously.

    The strange thing is if I do the same thing in VB, intelli-sense does show "Item" property.

    But I've yet to find a solution for the .Select method for selecting a specific row for either.


  • aftershock

    suedueno wrote:

    actually I never said that .item was a method..

    You indicated it as Item(), so that stands for a method because of the ().

    But anyway they shop up in my intelli-sense here. When you just type them and use them, do you get any error on compile time



  • HVE

    Error 4 'System.Windows.Forms.DataGridView' does not contain a definition for 'item'
  • MattP65

    actually I never said that .item was a method but for some reason it doesn't show up in intellisense for my datagrid instance;

     in 2003 .select selected a specified row, in 2005 it activates the control.


  • polmau

    I created a datagrid instance in code and I still didn't get "item" in intelli-sense. I've also read that the datagridview will be the future of the datagrid so it contains most of the same properties anyway.
  • dsmithwv

    Yes, please take a look at the error message again. You are using a DataGridView and not a DataGrid.


  • ttthanh23

    The DataGrid.Item() method didn't exists in .NET Framework 1.1, that is a DataGrid.Item property as still can be found in the .NET Framework 2.0 as you can see on MSDN.

    The DataGrid.Select() does also still exists in .NET Framework 2.0.

    So they are unchanged!


  • erb

    still no Item property in intellisense.

    I did figure out the row select method in 2005 though, dgv.RowsIdea.Select = true;
    which is slightly different from 2003, dgv.SelectIdea.


  • zoxter

    As i can see in the MSDN Documentation, the DatagridView class contains a Item property and a Select method as well.

    Can you share us the source that give's the error, because when i test it here. I can't get any error you talking about.


  • DBArchitect

    suedueno -

    Here what is happening. The item property is actually a named indexer property. In order to access this item in C#, you would use the "[ ]" syntax to set the value of that Item:

    dataGridView1[colIndex, rowIndex].Value = "foobar";

    Since this is a named indexer, it is accessible through VB with dataGridView1.Item(...)

    The MSDN documentation is misleading -- we're having our doc writers update this document.

    HTH,

    Karen



  • Martina23809

    suedueno -

    I can repro what you're seeing with the item property. Going to the metadata view of DataGridView (using Go to Definition) shows that the property isn't a member of DataGridView, which is why it's not showing up in IntelliSense.

    I've sent this post to members of the WinForms team though to see what's going on. I'll post back with results.

    Thanks!
    Karen



  • 2005 .item() & .Select() replacements?