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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange datagrid occurance

Status
Not open for further replies.

smithbr

MIS
May 29, 2003
85
0
0
US
Hello all,
I have a strange question about a datagrid I created at design time in VB.net. For some reason or another, my dtagrid displays as if it is part of parent child table. When I fill the datagrid, the datagrid closes almost and I have to click on the + in the upper left hand corner adn tehn the name of the table in order to view the data in the datagrid. Every time I refresh teh datagrid it returns to this collapsed state. Why is this happening and what do I have to do to get rid of this. The table is not a parent child table. Any suggestions?
Thanks,
Brent
 
Just set the DataMember property of your grid to your table.
 
I am sorry that I did not include that in my original post. I have the data source set the my dataset and teh data member set to the table. That is why I am so confused as to why it is doing this. I even started a whole new project and created a new datagrid and adapter, connection, etc. and I still had teh same thing happen.
 
I am sorry that I did not include that in my original post. I have the data source set the my dataset and teh data member set to the table. That is why I am so confused as to why it is doing this. I even started a whole new project and created a new datagrid and adapter, connection, etc. and I still had the same thing happen.
 

are you creating DataGridTableStyle and GridColumnStyle programmatically as well??? Can you post the code you have written



 
I created the datagrid and the datagridtablestyle at design time.

Here is the code i am using to fill the datagrid.

Private Sub cmdfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfind.Click

OleDbDataAdapter1.SelectCommand.Parameters(0).Value = txtinvnum.Text
OleDbDataAdapter1.Fill(DsInvoice1)
Try
DsInvoice1.Tables(0).Columns.Remove("Total")
Catch
End Try

DsInvoice1.Tables(0).Columns.Add("Total")
Dim dr As DataRow

If rdoyes.Checked Then
For Each dr In DsInvoice1.Tables(0).Rows
dr.Item("Total") = ((dr.Item("QuantityShipped") * dr.Item("LastUnitPrice")) * (1 - dr.Item("DiscountP")))
Next
grdComm.DataSource = Nothing
grdComm.DataSource = DsInvoice1
ElseIf rdono.Checked Then
For Each dr In DsInvoice1.Tables(0).Rows
dr.Item("Total") = dr.Item("QuantityShipped") * dr.Item("LastUnitPrice")

Next
grdComm.DataSource = Nothing
grdComm.DataSource = DsInvoice1
End If
End Sub
 

you didn't specify the DataMember property when you are binding the DataGrid to a data source

grdComm.DataSource = DsInvoice1 (no DataMember specified)

Try this !!!

myDataGrid.SetDataBinding(myDataSet, "myTable")


 
It worked...I had teh data member set at design time but did not realize taht the code was essentially overriding it. Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top