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

Binding Events to a Datagrid Column

Status
Not open for further replies.

dougconran

Technical User
Sep 26, 2003
89
GB
I need to change the text displayed in a datagrid at the time of display.

I found an excellent articale at


explaining how I can do this by creating a binding event and then making the change within the binding_Format event.

Unfortunately the article describes how to do this for a textbox whereas I need to do it for a Datagrid and I can't work out what changes I need to make.

Currently I create a TableStyle in the form_load event and have the binding code within this - but it doesn't work :(

This is my code:-

Code:
    Dim WithEvents obinding As Binding
...
...
...
                    BoolCol.HeaderText = "Compliant?"  '  should display as Yes/No
                    obinding = New Binding("Text", DataSet11.welds.Columns(i), DataSet11.Tables(0).Columns(i).ColumnName)   <-- I suspect this is wrong
                    DataGrid1.DataBindings.Add(obinding)
                    BoolCol.MappingName = DataSet11.Tables(0).Columns(i).ColumnName
                    tableStyle.GridColumnStyles.Add(BoolCol)

I suspect that the binding statement is wrong but none of the variations that I can think of will work.

Can anyone suggest what I'm doing wrong?

TIA

Doug
 
I've done some further changes and have got the binding working but am now having a problem actually changing the value.

1. The change I made to the statement is:

obinding = New Binding("Text", DataSet11.welds, "table colname")

2. I stuck a message display command in the binding_format event and (a) it only displays when the column value is False and (b) in spite of changing the e.Value, what is displayed doesn't change.

Part of the problem seems to be that I can't cast a boolean to text, even though it is declared as a text column in the tablestyle.

Any other suggestions?

TIA

Doug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top