Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Question

Status
Not open for further replies.

KeyserSoze1877

Programmer
Sep 6, 2001
95
US
I am a newbie to VB 2005, was decent in VB 6. I have a program I am writing to get the hang on .NET so I am writing an RSS reader.

I used some code as a model to populate a datagridview as my temporary holding area of the XML config and the RSS feeds to traverse. No problem. I load my XML which has the site name and URL, the grid loads ok. But...

I want to load a combo box with the sitenames of however may sites are in the config XML.

Here's the code...

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filePath As String = "RSSXML.xml"
Dim dsRss As New DataSet

dsRSS.ReadXml(filePath)
dgrdRSS.DataMember = "RSSEntry"
dgrdRSS.DataSource = dsRSS

' The grid loads fine with proper data

PopulateComboBox() ' Pop Function
End Sub

Private Sub PopulateComboBox()
Dim j As Integer = 0

For j = 0 To dgrdRSS.RowCount
cmbRSS.Items.Add(dgrdRSS.Item(1, j))
j = j + 1

Next j
End Sub

It loops through fine, but in the code that I used as a tutorial the datagrad.item(1,1) showed the value of the cell at 1 column, 1 row.... but when I do it I get ALL this as output:
==========================
{System.Windows.Forms.DataGridViewTextBoxCell}
System.Windows.Forms.DataGridViewTextBoxCell: {System.Windows.Forms.DataGridViewTextBoxCell}
AccessibilityObject: {System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject}
ColumnIndex: 1
ContentBounds: {X = 0 Y = 3 Width = 97 Height = 15}
ContextMenuStrip: Nothing
DataGridView: {System.Windows.Forms.DataGridView}
DefaultNewRowValue: Nothing
Displayed: True
EditedFormattedValue: " EditType: {Name = "DataGridViewTextBoxEditingControl" FullName = "System.Windows.Forms.DataGridViewTextBoxEditingControl"}
ErrorIconBounds: {X = 0 Y = 0 Width = 0 Height = 0}
ErrorText: ""
FormattedValue: " FormattedValueType: {Name = "String" FullName = "System.String"}
Frozen: False
HasStyle: False
InheritedState: 89
InheritedStyle: {System.Windows.Forms.DataGridViewCellStyle}
IsInEditMode: False
OwningColumn: {System.Windows.Forms.DataGridViewTextBoxColumn}
OwningRow: {System.Windows.Forms.DataGridViewRow}
PreferredSize: {Width = 282 Height = 20}
ReadOnly: False
Resizable: True
RowIndex: 0
Selected: False
Size: {Width = 100 Height = 22}
State: None {0}
Style: {System.Windows.Forms.DataGridViewCellStyle}
Tag: Nothing
ToolTipText: ""
Value: " ValueType: {Name = "String" FullName = "System.String"}
Visible: True
============================

What am I missing?

---------------
Keyser Soze
"Vote Pedro.
 
Try changing this

cmbRSS.Items.Add(dgrdRSS.Item(1, j))

to This

cmbRSS.Items.Add(dgrdRSS.Rows.Item(RowNum).Cells(CellNum).Value)
 
You da man/girl... that worked.

---------------
Keyser Soze
"Vote Pedro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top