WinForms FAQ

  • Thread starter Thread starter Rob Panosh
  • Start date Start date
Rob,

Are you sure that it is not just temporary, on the homepage is still a
complete link to this pages however are empty.

So just ask what you are searching for here temporary maybe some of us knows
another link.

Cor
 
Since you asked, I'm currently looking for VB.Net code to add a combobox
to a DataGrid Column.... I've found C# code, but not VB.Net.

Thanks,
Aaron
 
Aaron,

It seems for me as if the Google newsgroup are a mash as well,

I thought that this one is the simple comboboxcolumn that is as well as
sample on syncfusion a little bit changed by me to let it go as well with
option strict on.

\\\
Public Class DgComboBoxColumn
Inherits DataGridTextBoxColumn
Public WithEvents ColumnComboBox As DataGridCombo 'special class
Private WithEvents cmSource As CurrencyManager
Private mRowNum As Integer
Private isEditing As Boolean
Shared Sub New()
End Sub
Public Sub New()
MyBase.New()
ColumnComboBox = New DataGridCombo
AddHandler ColumnComboBox.SelectionChangeCommitted, _
New EventHandler(AddressOf ComboStartEditing)
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager,
_
ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As
Boolean, _
ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, readOnly1, instantText,
cellIsVisible)
mRowNum = rowNum
cmSource = source
ColumnComboBox.Parent = Me.TextBox.Parent
ColumnComboBox.Location = Me.TextBox.Location
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width,
ColumnComboBox.Size.Height)
ColumnComboBox.Text = Me.TextBox.Text
TextBox.Visible = False
ColumnComboBox.Visible = True
ColumnComboBox.BringToFront()
ColumnComboBox.Focus()
End Sub
Protected Overloads Overrides Function Commit(ByVal dataSource As _
CurrencyManager, ByVal rowNum As Integer) As Boolean
If isEditing Then
isEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As
EventArgs)
isEditing = True
MyBase.ColumnStartedEditing(DirectCast(sender, Control))
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
_
Handles ColumnComboBox.Leave
If isEditing Then
SetColumnValueAtRow(cmSource, mRowNum, ColumnComboBox.Text)
isEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
End Sub
End Class

This one is when you want to use valuemembers, I made it as well from a
sample that is as well on syncfusion and changed as well some parts and in
that thread was an improvement again by the original poster. The thread was
longer however that improvement is gone. However you can try this one when
you need that valuemember otherwise I would when I was you try the first
one.

http://tinyurl.com/49p35

This link is another datagrid faq page

http://www.microsoft.com/belux/nl/msdn/community/columns/jtielens/datagrid.mspx

Give it a try, I hope this helps?

Cor.
 
Thank you.. I'm going to give it a try and see what happens. I
downloaded Leadit's ExtendedDataGrid, but while trying to get it to
work, I got very frustrated.. Since I couldn't see any of the code, I
couldn't figure out how to make the combobox one work and there were no
samples available...

Aaron

Cor said:
Aaron,

It seems for me as if the Google newsgroup are a mash as well,

I thought that this one is the simple comboboxcolumn that is as well as
sample on syncfusion a little bit changed by me to let it go as well with
option strict on.

\\\
Public Class DgComboBoxColumn
Inherits DataGridTextBoxColumn
Public WithEvents ColumnComboBox As DataGridCombo 'special class
Private WithEvents cmSource As CurrencyManager
Private mRowNum As Integer
Private isEditing As Boolean
Shared Sub New()
End Sub
Public Sub New()
MyBase.New()
ColumnComboBox = New DataGridCombo
AddHandler ColumnComboBox.SelectionChangeCommitted, _
New EventHandler(AddressOf ComboStartEditing)
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager,
_
ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As
Boolean, _
ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, readOnly1, instantText,
cellIsVisible)
mRowNum = rowNum
cmSource = source
ColumnComboBox.Parent = Me.TextBox.Parent
ColumnComboBox.Location = Me.TextBox.Location
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width,
ColumnComboBox.Size.Height)
ColumnComboBox.Text = Me.TextBox.Text
TextBox.Visible = False
ColumnComboBox.Visible = True
ColumnComboBox.BringToFront()
ColumnComboBox.Focus()
End Sub
Protected Overloads Overrides Function Commit(ByVal dataSource As _
CurrencyManager, ByVal rowNum As Integer) As Boolean
If isEditing Then
isEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As
EventArgs)
isEditing = True
MyBase.ColumnStartedEditing(DirectCast(sender, Control))
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
_
Handles ColumnComboBox.Leave
If isEditing Then
SetColumnValueAtRow(cmSource, mRowNum, ColumnComboBox.Text)
isEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
End Sub
End Class

This one is when you want to use valuemembers, I made it as well from a
sample that is as well on syncfusion and changed as well some parts and in
that thread was an improvement again by the original poster. The thread was
longer however that improvement is gone. However you can try this one when
you need that valuemember otherwise I would when I was you try the first
one.

http://tinyurl.com/49p35

This link is another datagrid faq page

http://www.microsoft.com/belux/nl/msdn/community/columns/jtielens/datagrid.mspx

Give it a try, I hope this helps?

Cor.
 
Cor,

I can't seem to get it to work... I added a TextBox column style, then
went into the code and changed it from that to the new name of the
combobox style, and once I switched back to the designer, the column
disappeared.. It's still in code, but it doesn't show up on the screen,
even when run...

Cor said:
Aaron,

It seems for me as if the Google newsgroup are a mash as well,

I thought that this one is the simple comboboxcolumn that is as well as
sample on syncfusion a little bit changed by me to let it go as well with
option strict on.

\\\
Public Class DgComboBoxColumn
Inherits DataGridTextBoxColumn
Public WithEvents ColumnComboBox As DataGridCombo 'special class
Private WithEvents cmSource As CurrencyManager
Private mRowNum As Integer
Private isEditing As Boolean
Shared Sub New()
End Sub
Public Sub New()
MyBase.New()
ColumnComboBox = New DataGridCombo
AddHandler ColumnComboBox.SelectionChangeCommitted, _
New EventHandler(AddressOf ComboStartEditing)
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager,
_
ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As
Boolean, _
ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, readOnly1, instantText,
cellIsVisible)
mRowNum = rowNum
cmSource = source
ColumnComboBox.Parent = Me.TextBox.Parent
ColumnComboBox.Location = Me.TextBox.Location
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width,
ColumnComboBox.Size.Height)
ColumnComboBox.Text = Me.TextBox.Text
TextBox.Visible = False
ColumnComboBox.Visible = True
ColumnComboBox.BringToFront()
ColumnComboBox.Focus()
End Sub
Protected Overloads Overrides Function Commit(ByVal dataSource As _
CurrencyManager, ByVal rowNum As Integer) As Boolean
If isEditing Then
isEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As
EventArgs)
isEditing = True
MyBase.ColumnStartedEditing(DirectCast(sender, Control))
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
_
Handles ColumnComboBox.Leave
If isEditing Then
SetColumnValueAtRow(cmSource, mRowNum, ColumnComboBox.Text)
isEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
End Sub
End Class

This one is when you want to use valuemembers, I made it as well from a
sample that is as well on syncfusion and changed as well some parts and in
that thread was an improvement again by the original poster. The thread was
longer however that improvement is gone. However you can try this one when
you need that valuemember otherwise I would when I was you try the first
one.

http://tinyurl.com/49p35

This link is another datagrid faq page

http://www.microsoft.com/belux/nl/msdn/community/columns/jtielens/datagrid.mspx

Give it a try, I hope this helps?

Cor.
 
Ok, fixed it.. I just need to read more. :P

Aaron said:
Cor,

I can't seem to get it to work... I added a TextBox column style, then
went into the code and changed it from that to the new name of the
combobox style, and once I switched back to the designer, the column
disappeared.. It's still in code, but it doesn't show up on the screen,
even when run...
 
Herfried said:
Interesting -- the website still works for me ;-).

I just tried it again.. Still nothing.. I'm going to their main page and
it comes up, but when I click on the Winforms FAQ at the bottom right, I
get that server too busy message. Maybe the server is just too busy for
me. lol
 
Thats odd.. That works for me but using the full DNS doesn't.. It worked
from home last night too. I'll send them an e-mail..

Aaron
 

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

Back
Top