Create a customized DataGridViewColumn

G

Guest

I would like to create a customized DataGridViewColumn called
DataGridViewCheckedListBoxColumn. I'd like the ability to multi-select items
in the list. Does anyone know of an example of how this is done?
 
J

Jeffrey Tan[MSFT]

Hi Steve,

Creating customized column in DataGridView is build-in supported in its
control model. To achieve this, you should complete the following 3 tasks:
1. Define classes that derive from DataGridViewColumn.
2. Define classes that derive from DataGridViewCell.
3. Define a class that derives from Control and implements the
IDataGridViewEditingControl interface.

Since you want to define a DataGridViewCheckedListBoxColumn, you may use
the build-in CheckedListBox control/class to complete these 3 tasks. The 2
articles below provided the detailed information and sample code regarding
creating customized column in DataGridView in both C# and VB.net:
"How to: Host Controls in Windows Forms DataGridView Cells"
http://msdn2.microsoft.com/en-us/library/7tas5c80.aspx
"How to: Customize Cells and Columns in the Windows Forms DataGridView
Control by Extending Their Behavior and Appearance "
http://msdn2.microsoft.com/en-us/library/7fb61s43.aspx

By following the sample code and steps, it is not hard to create out the
DataGridViewCheckedListBoxColumn.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

I'll review this material and see if I can get the customized column
implemented. Thanks for the lead. I'll let you know the results.
 
J

Jeffrey Tan[MSFT]

Ok, I will continue to monitor this thread for any feedback.

Additionally, another trick for this issue is using Reflector to view the
source code of existing well-working DataGridView***Column implementation.
For example, you may use Reflector to view various methods/properties code
of DataGridViewButtonColumn class. It will provide much useful information
to you.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Steve,

*Reflector* is a tool written by Microsoft engineer Lutz Roeder. It uses
.Net Reflection to parse the internal information of the .Net FCL
assemblies. It also decomplies the MSIL code in the FCL into various
languages, such as C#, VB.net, IL etc... It is somewhat like ILdasm.exe in
.Net Framework, but provides higher level language(C#) display. Using it,
you can see the source code of .Net FCL. It is a must have tool for .Net
developer. You may download it for free in the link below:
http://www.aisto.com/roeder/dotnet/

In your scenario, you may use Reflector to view the source code of such as
DataGridViewButtonColumn class, which provides you a complete sample
implementation.

If you still have anything unclear, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Steve,

Glad to hear that. If you meet any problem that is hard to workaround,
please feel free to post here, we will discuss with you on it.

Additionally, by going through implementing the customized
DataGridViewColumn, you will get a deeper understanding of DataGridView
column model. :)

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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