1 datagrid, multiple tables and tablestyles

H

henk

Hi,
I have a vb.net application where I need multiple "Lookup windows".
I could make 10 lookup window with each there own datagrid and table
style, but I want to do it Nice.
I was thinking about 1 Lookupwindow with 2 parameters (SQL and the
tablestyle).
The problem is: When calling the lookup window, it works ok. But when
calling another Lookup window the table style won't update. (it still
uses the first one).

Anybody an idea?

Thanks in advance.

I use:
dsLookup.Clear()
cCommand = frmMain.GlcCommand
' create a data adapter
Dim daStudy As OleDbDataAdapter = New
OleDbDataAdapter(cCommand, frmMain.myConnection)
dsLookup.Clear()
dsLookup.DataSetName = frmMain.GlcTS
'daStudy.Update(dsLookup, frmMain.GlcTS)
' fill dataset
daStudy.TableMappings.Clear()
daStudy.Fill(dsLookup, frmMain.GlcTS)
 
C

Cor Ligthert [MVP]

Henk,

I had this problem as well. The most simple solution was than always to set
tablestyle zero to nothing and than add the needed one.

I hope this helps,

Cor
 
H

henk

Hi

Thanks for your answer.
I made 2 tablestyles with the properties window of the datagrid.
Did you make the tablestyles with code?
Maybe you have an example??

Thanks
Henk,
The Netherlands
 
B

Bart Mermuys

Hi,

henk said:
Hi

Thanks for your answer.
I made 2 tablestyles with the properties window of the datagrid.

Ok, so did you set a MappingName for each table style ? When you bind to a
grid then the name of the DataTable is used to find the TableStyle with an
equal MappingName and that one will be used.

So make sure that your tables have the right TableName and that each
DataGridTableStyle has the right MappingName.

Public Sub BindGrid( Query As String, TableName As String )
Dim lookupAdapter As OleDbDataAdapter =
New OleDbDataAdapter( Query, frmMain.myConnection)

Dim lookupTable As New DataTable( TableName )
lookupAdapter.Fill( lookupTable )

LookupDataGrid.DataSource = lookupTable
End Sub
Did you make the tablestyles with code?

You could also do that, but it's not entirely clear whether you want to keep
all TableStyles in the LookupForm or not.

HTH,
Greetings
 
C

Cor Ligthert [MVP]

Henk,

Sorrry a litle bit "te kort door de bocht"
:)
DataLookup1.TableStyles.RemoveAt(0)

I hope this helps better,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top