|
-
Jul 4th, 2006, 06:34 PM
#1
Thread Starter
Member
[2003] Datagrid row coloring
Hi,
This is my first post in here, I will describe my situation. I would like to change the color of a row based on a boolean value. So what I did was, I used a class called DataGridColoredTextBoxColumn which extends DataGridTextBoxColumn. I have a paint method there which is overriden.
In my code, when the control is being loaded:
VB Code:
Try
If designmode Then
Return
End If
AddHandler MainForm.Data.Items.RowChanged, AddressOf ItemRowChanged
AddHandler MainForm.Data.Items.RowChanging, AddressOf RowChanging
AddHandler MainForm.Data.Items.RowDeleted, AddressOf RowDeleted
AddHandler MainForm.Data.Items.RowDeleting, AddressOf RowDeleting
AddHandler MainForm.Data.Items.ColumnChanged, AddressOf ColumnChanged
Dim i As Integer = 0
For Each c As DataColumn In MainForm.Data.Items.Columns
ct = New DataGridColoredTextBoxColumn
ct.MappingName = c.ColumnName
ct.HeaderText = c.ColumnName
ct.NullText = ""
Select Case c.ColumnName.Trim
Case "PO No."
ct.HeaderText = "PO#"
ct.Width = 30
Case "Description"
ct.HeaderText = "Item Code - Description"
ct.Width = 280
' ... for all columns
End Select
Try
dg.TableStyles(0).GridColumnStyles.Add(ct)
If ct.MappingName = "Description" Then
ct = New DataGridTextBoxColumn
ct.MappingName = "Item Code"
ct.HeaderText = "Alpha Code"
ct.NullText = ""
ct.Width = 100
dg.TableStyles(0).GridColumnStyles.Add(ct)
End If
Catch ex As Exception
End Try
i += 1
DoNext:
Next
dg.DataSource = MainForm.Data
dg.DataMember = "Items"
Catch ex As Exception
PromptMessage(ex.Message, "Error", FrmMessage.ButtonModes.OK, FrmMessage.MessageTypes.ErrorType, ex)
End Try
I use a listbox which is added to a column of a textbox to add a new row...
The problem with this code is that paint method is called when I add a new row, but I would really like to call it after the row is added. Currently the paint method is being called as soon as I click on the list box which will add a a new row. untill a row is added I cannot retrieve the boolean value which will set the row's color.
Hope that makes sense.
thanks...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|