Click here to Skip to main content
15,888,521 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: True DBGrid in vb 6.0 Pin
noshaba mariam7-Mar-06 23:05
noshaba mariam7-Mar-06 23:05 
GeneralRe: True DBGrid in vb 6.0 Pin
Dave Kreskowiak8-Mar-06 0:23
mveDave Kreskowiak8-Mar-06 0:23 
Questioninserting image in sql server 2000 Pin
uglyeyes7-Mar-06 13:05
uglyeyes7-Mar-06 13:05 
AnswerRe: inserting image in sql server 2000 Pin
Steve Pullan7-Mar-06 13:41
Steve Pullan7-Mar-06 13:41 
GeneralRe: inserting image in sql server 2000 Pin
uglyeyes7-Mar-06 17:30
uglyeyes7-Mar-06 17:30 
Questionmultiple web chart in a data repeater. Pin
uglyeyes7-Mar-06 11:51
uglyeyes7-Mar-06 11:51 
AnswerRe: multiple web chart in a data repeater. Pin
Dave Kreskowiak7-Mar-06 13:53
mveDave Kreskowiak7-Mar-06 13:53 
QuestionDatagrid custom columnstyle problem Pin
David M J7-Mar-06 11:48
David M J7-Mar-06 11:48 
Hi,
I've got a problem with my custum datagridcolumnstyles. As soon as I sort on a column with a custom column style after I have selected a different row, the code redraws a label(which is the columnstyle in the attached code snippet) the size of the entire grid. Also when changing the readonly status of the datagrid the datagrid seems to "freeze". I am probably missing something, but I am not sure what. Any suggestions? The attached code is converted from C# to vb so there might be some error there.


Thanks
David

Public Class clDTRDataGridLabelColumn
Inherits DataGridColumnStyle
Private lb As New Label
' The isEditing field tracks whether or not the user is
' editing data with the hosted control.
Private isEditing As Boolean

Public Sub New()
lb.Visible = False

lb.Dock = DockStyle.Fill
Me.NullText = ""
'tb.Height = 27
End Sub

Protected Overrides Sub Abort(ByVal rowNum As Integer)
isEditing = False
RemoveHandler lb.TextChanged, _
AddressOf lbtextChanged
Invalidate()
End Sub

Protected Overrides Function Commit _
(ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _
As Boolean
lb.Bounds = Rectangle.Empty

AddHandler lb.TextChanged, _
AddressOf lbtextChanged

If Not isEditing Then
Return True
End If
isEditing = False

Invalidate()
Return True
End Function

Protected Overloads Overrides Sub Edit( _
ByVal [source] As CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
Dim value As String
If cellIsVisible Then

lb.Text = value
lb.Visible = True
AddHandler lb.TextChanged, _
AddressOf lbtextChanged
Else
lb.Text = value
lb.Visible = False
End If

If lb.Visible Then
DataGridTableStyle.DataGrid.Invalidate(bounds)
End If
End Sub

Protected Overrides Function GetPreferredSize( _
ByVal g As Graphics, _
ByVal value As Object) As Size
Return New Size(100, lb.PreferredHeight)
End Function

Protected Overrides Function GetMinimumHeight() As Integer
Return lb.PreferredHeight
End Function


Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal value As Object) As Integer
Return lb.PreferredHeight
End Function


Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer)
Paint(g, bounds, [source], rowNum, False)
End Sub

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)
Paint(g, bounds, [source], rowNum, Brushes.Red, Brushes.Blue, alignToRight)
End Sub

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)

Dim str As String
Dim rect As Rectangle = bounds
If Not GetColumnValueAtRow([source], rowNum) Is DBNull.Value Then
str = CType(GetColumnValueAtRow([source], rowNum), String)
Else
str = ""
End If
If rowNum = Me.DataGridTableStyle.DataGrid.CurrentRowIndex Then
backBrush = New SolidBrush(Me.DataGridTableStyle.SelectionBackColor)
End If
g.FillRectangle(backBrush, rect)
rect.Offset(0, 0)

g.DrawString(str, Me.DataGridTableStyle.DataGrid.Font, foreBrush, RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))
Console.WriteLine(bounds.Width & " " & bounds.Height & " " & Me.HeaderText)
End Sub

Protected Overrides Sub SetDataGridInColumn(ByVal value As DataGrid)
MyBase.SetDataGridInColumn(value)
If Not (lb.Parent Is Nothing) Then
lb.Parent.Controls.Remove(lb)
End If
If Not (value Is Nothing) Then
value.Controls.Add(lb)
End If
End Sub

Private Sub lbtextChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.isEditing = True
MyBase.ColumnStartedEditing(lb)
End Sub
End Class

Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
QuestionCustom .NET control and collection persistence Pin
rhorc7-Mar-06 11:40
rhorc7-Mar-06 11:40 
QuestionClosing Main Form Pin
jdjd11187-Mar-06 7:24
jdjd11187-Mar-06 7:24 
AnswerRe: Closing Main Form Pin
Chatura Dilan7-Mar-06 14:19
Chatura Dilan7-Mar-06 14:19 
QuestionDatabase Replication Pin
jdjd11187-Mar-06 7:21
jdjd11187-Mar-06 7:21 
AnswerRe: Database Replication Pin
Steve Pullan7-Mar-06 11:12
Steve Pullan7-Mar-06 11:12 
QuestionCombobox events Pin
eatwork7-Mar-06 6:17
eatwork7-Mar-06 6:17 
QuestionNeed Advice Pin
Darshon7-Mar-06 5:47
Darshon7-Mar-06 5:47 
AnswerRe: Error reading database file when deploying a vb.net project? Pin
H@is@here7-Mar-06 5:57
H@is@here7-Mar-06 5:57 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
Rashar7-Mar-06 6:12
Rashar7-Mar-06 6:12 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
H@is@here7-Mar-06 6:28
H@is@here7-Mar-06 6:28 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
Rashar7-Mar-06 12:31
Rashar7-Mar-06 12:31 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
H@is@here7-Mar-06 22:53
H@is@here7-Mar-06 22:53 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
Rashar8-Mar-06 2:17
Rashar8-Mar-06 2:17 
GeneralRe: Error reading database file when deploying a vb.net project? Pin
Rashar8-Mar-06 5:38
Rashar8-Mar-06 5:38 
QuestionAxWebBrowser without form support Pin
Sufyan_shani7-Mar-06 4:47
Sufyan_shani7-Mar-06 4:47 
AnswerRe: AxWebBrowser without form support Pin
Dave Kreskowiak7-Mar-06 5:23
mveDave Kreskowiak7-Mar-06 5:23 
GeneralRe: AxWebBrowser without form support Pin
Darshon7-Mar-06 5:33
Darshon7-Mar-06 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.