DataGrid

G

Guest

Hello

I need somebody’s help with the following

I tried to display data to a DataGrid, that is not the problem
But if I try to add a TableStyle to a DataGrid then I don’t get a result ( no data)

If I use the next code, but without a TableStyle, it works
----------------------------------------------------------------------------------------------------------------
'Declaratie
Dim strMedewerker As Strin

'Set de standaard medewerker in de strMedewerker strin
strMedewerker = "Marco Di Gregorio

'Alle velden leegmake
If DataGridWijziging.Text >= "" The
txtBeginDatum.Text = "
txtEindDatum.Text = "
objDsDGWijziging.Tables.Clear(
DataGridWijziging.DataSource = Nothin
End I

'Datagrid vernieuwe
DataGridWijziging.Refresh(

If txtEindDatum.Text = "" And txtBeginDatum.Text = "" The
'Set de geselecteerd datum in de txtBeginDatum en txtEindDatu
txtBeginDatum.Text = WijzigingsKalender.SelectionStar
txtEindDatum.Text = WijzigingsKalender.SelectionEn
Els

End I

'Connectie make
Dim objConn As OleDb.OleDbConnection = Connectie(

'OleDbCommand voor het uitvoeren van de SQL script aanmake
Dim cmd As New OleDbCommand("SELECT Activiteitomschrijving, Medewerker, Datum, Uren FROM Query_InvoerUren WHERE Medewerker ='" & strMedewerker & "' AND Datum BETWEEN @beginDatum And @EindDatum", objConn
cmd.Parameters.Add("@BeginDatum", CDate(txtBeginDatum.Text)
cmd.Parameters.Add("@EindDatum", CDate(txtEindDatum.Text)
Dim objADaDGWijziging As New OleDbDataAdapter(cmd

'objDatasetDataGridWijziging vulle
objADaDGWijziging.Fill(objDsDGWijziging


'DataGrid vulle
'DataGridWijziging.PreferredColumnWidth = 15
DataGridWijziging.DataSource = objDsDGWijziging.Tables(0
----------------------------------------------------------------------------------------------------------------


If I add the next code then I won’t get my result
----------------------------------------------------------------------------------------------------------------

Dim DaGridTableStyle As New DataGridTableStyl

With DaGridTableStyl
.AlternatingBackColor = Color.GhostWhit
.BackColor = Color.GhostWhit
.ForeColor = Color.MidnightBlu
.GridLineColor = Color.RoyalBlu
.HeaderBackColor = Color.MidnightBlu
.HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold
.HeaderForeColor = Color.Lavende
.SelectionBackColor = Color.Tea
.SelectionForeColor = Color.PaleGree
.MappingName = "Query_InvoerUren
.PreferredRowHeight = 1
End Wit

Dim DataGridColStyle1 As New DataGridTextBoxColum
With DataGridColStyle
.HeaderText = "Medewerker
.MappingName = "Medewerker
.Width = 4
.ReadOnly = Tru
End Wit

Dim DataGridColStyle2 As New DataGridTextBoxColum
With DataGridColStyle
.HeaderText = "Activiteitomschrijving
.MappingName = "Activiteitomschrijving
.Width = 15
.ReadOnly = Tru
End Wit

Dim DataGridColStyle3 As New DataGridTextBoxColum
With DataGridColStyle
.HeaderText = "Datum
.MappingName = "Datum
.Width = 2
.ReadOnly = Tru
End Wit

Dim DataGridColStyle4 As New DataGridTextBoxColum
With DataGridColStyle
.HeaderText = "Uren
.MappingName = "Uren
.Width = 1
.ReadOnly = Fals
End Wit

' Add the style objects to the table style's collection of
' column styles. Without this the styles do not take effect.
DaGridTableStyle.GridColumnStyles.AddRange
(New DataGridColumnStyle()
{DataGridColStyle1, DataGridColStyle2, DataGridColStyle3, DataGridColStyle4}
DataGridWijziging.TableStyles.Add(DaGridTableStyle)
 
C

Cor

Hi Marco,

First some advices when you post to a newsgroup.
When you have a question, make a new message never attach it to someone
elses message.
That one things he gets an answer.

Second one only send a piece of code, normaly nobody looks to this amount of
code if he has not asked for it

I think the error can be that I mis.

DaGridTableStyle.MappingName="Query_InvoerUren"

If not, my advice to delete some of the code (all those columnstyles except
one) and bring back the essentials in this newsgroup as a new message.

Than we can read it more easily

(Althought I expect that the error is that mappingName)

I hope this helps?

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