473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataGrid custom class

I have the following Class, but I would like to make one of the columns in
my DataGrid editable, how would I do that? When I use this class none of
the columns are editable even when I set the ReadOnly property to false?

Thanks
Peter
'-------------------------------------------------
Public Class MyDataGrid
Inherits DataGrid

Private _processVars As ProcessVariables
Private _sortDir As String = "NONE"
Private _sortVar As String = "NONE"

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)

Dim pt As New Point(e.X, e.Y)

Dim hit As DataGrid.HitTestInfo = Me.HitTest(pt)

If hit.Type = HitTestType.ColumnHeader AndAlso (hit.Column = 1 Or
hit.Column = 2) Then
Dim col As String =
Me.TableStyles(0).GridColumnStyles(hit.Column).Map pingName

If Me._sortVar.Equals(col) Then
If hit.Column = 1 Then
If Me._sortDir.Equals("ASC") Then
Me._sortDir = "DESC"
ElseIf Me._sortDir = "DESC" Then
Me._sortDir = "NONE"
Else
Me._sortDir = "ASC"
End If
Else
If Me._sortDir.Equals("ASC") Then
Me._sortDir = "DESC"
Else
Me._sortDir = "ASC"
End If
End If
Else
Me._sortDir = "DESC"
Me._sortVar = col
End If

Me._processVars.SortGrid(Me, Me._sortDir, Me._sortVar)
Return 'don't call baseclass

End If

MyBase.OnMouseDown(e)

End Sub 'OnMouseDown

Public WriteOnly Property ProcessVars() As ProcessVariables
Set(ByVal Value As ProcessVariables)
Me._processVars = Value
End Set
End Property
End Class 'MyDataGrid
Aug 2 '06 #1
20 1158
This should do the trick:
http://www.syncfusion.com/FAQ/Window...44c.aspx#q758q

(5.18)
Aug 2 '06 #2
Pieter has give us a good sample to do the trick. You can make all other
columns non-editable to make one column editable.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 2 '06 #3
Hi Peter,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 7 '06 #4
Why do I never get such a help from Microsoft? :-)
Aug 7 '06 #5
Pieter,

Because you probably don't use the webbased newsgroupreader and than does
not log on with your MSDN emailadres (account)

Otherwise there will be at least action taken on your question (checked if
there is already given a good answer (as Kevin did with yours and replied in
this case to check if the answer was as wanted), given an answer or bring
the answer back to their backoffice and reply accoording to that).

Cor

"Pieter" <pi**********@hotmail.comschreef in bericht
news:up****************@TK2MSFTNGP06.phx.gbl...
Why do I never get such a help from Microsoft? :-)

Aug 7 '06 #6

"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:y$**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
When I create a sample application it works, but in my application that I am
working on it does not work. The cursor goes into the grid cell like you
can edit the contents, but when I press a key nothing happens.
Aug 7 '06 #7
Peter,

Than in your case I would check the code of your application again. There
has never been any magic in code.

It works or it does not works, maybe you have used a wrong variable name or
not filled it with the right data. It is mostly hard to give any help in
that.

Cor
"Peter" <pc*****@nospam.nospamschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:y$**************@TK2MSFTNGXA01.phx.gbl...
>Hi Peter,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
================================================= =

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

When I create a sample application it works, but in my application that I
am working on it does not work. The cursor goes into the grid cell like
you can edit the contents, but when I press a key nothing happens.

Aug 7 '06 #8
Pieter,

That does not mean that you cannot get an answer from Kevin, Jeffrey or
other Microsoft people if you don't do that, but than they do it completely
as community member, free to do that or not.

Cor

"Pieter" <pi**********@hotmail.comschreef in bericht
news:up****************@TK2MSFTNGP06.phx.gbl...
Why do I never get such a help from Microsoft? :-)

Aug 7 '06 #9
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Because you probably don't use the webbased newsgroupreader and than does
not log on with your MSDN emailadres (account)
Ah, it HAS to be the web-based email-account? I'm using Outlook Express. I
tried it some time ago with the special-made MDSN-emaialdres, but I still
din't get answers :-)
Aug 8 '06 #10
Yes, Pieter. Try to use web-based community and your registered MSDN email
address. And you'll be replied within 24 hours.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 9 '06 #11
Hi Peter,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 11 '06 #12

"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:ZF**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
I have not resolved my problem yet.

The problem is with my custom class the "MyDataGrid"
because when I use datagrid directly it works, but when I inherit the
DataGrid in MyDataGrid it does not work.

It's like my class is cosumming the KeyPress Event but it's never doing
anything with them.

here's the class again
'-------------------------------------------------
Public Class MyDataGrid
Inherits DataGrid

Private _processVars As ProcessVariables
Private _sortDir As String = "NONE"
Private _sortVar As String = "NONE"

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)

Dim pt As New Point(e.X, e.Y)

Dim hit As DataGrid.HitTestInfo = Me.HitTest(pt)

If hit.Type = HitTestType.ColumnHeader AndAlso (hit.Column = 1 Or
hit.Column = 2) Then
Dim col As String =
Me.TableStyles(0).GridColumnStyles(hit.Column).Map pingName

If Me._sortVar.Equals(col) Then
If hit.Column = 1 Then
If Me._sortDir.Equals("ASC") Then
Me._sortDir = "DESC"
ElseIf Me._sortDir = "DESC" Then
Me._sortDir = "NONE"
Else
Me._sortDir = "ASC"
End If
Else
If Me._sortDir.Equals("ASC") Then
Me._sortDir = "DESC"
Else
Me._sortDir = "ASC"
End If
End If
Else
Me._sortDir = "DESC"
Me._sortVar = col
End If

Me._processVars.SortGrid(Me, Me._sortDir, Me._sortVar)
Return 'don't call baseclass

End If

MyBase.OnMouseDown(e)

End Sub 'OnMouseDown

Public WriteOnly Property ProcessVars() As ProcessVariables
Set(ByVal Value As ProcessVariables)
Me._processVars = Value
End Set
End Property
End Class 'MyDataGrid

Aug 14 '06 #13
Hi Peter,

I checked your code and found that currently, your control is allowing all
the columns to be editable, because at the end of OnMouseDown, you're
calling MyBase.OnMouseDown(e). So, if you only need the columns that meets
the criteria to be editable, you can put MyBase.OnMouseDown(e) inside the
if block.

Also, I don't quite understand why you use If hit.Type =
HitTestType.ColumnHeader AndAlso (hit.Column = 1 Or hit.Column = 2). Are
you allowing the second and third column to be editable? Or sortable?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 14 '06 #14

"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:nV**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

I checked your code and found that currently, your control is allowing all
the columns to be editable, because at the end of OnMouseDown, you're
calling MyBase.OnMouseDown(e). So, if you only need the columns that meets
the criteria to be editable, you can put MyBase.OnMouseDown(e) inside the
if block.

Also, I don't quite understand why you use If hit.Type =
HitTestType.ColumnHeader AndAlso (hit.Column = 1 Or hit.Column = 2). Are
you allowing the second and third column to be editable? Or sortable?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
I am allowing second and 3rd column to be sortable.

My problem is that I am not able to edit any of the columns, the cursor goes
into a cell like it would allow you to edit, but when I type nothing shows
up on the screen. If I don't use my custom class just grid directly
everything works, but if I use my class and inherit the DataGrid class it
does not work, so I know the problem is with my class, but I don't know how
or what to fix.
Aug 14 '06 #15
Hi Peter,

The MyDataGrid control works fine on my machine. When I press the key, a
certain cell can be edited. Have you ever handle the key events of the
Textbox in that cell?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 15 '06 #16
I'm using exactly the code you have provided in your last post.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 15 '06 #17
Hi Peter,

Is there anything that I can help at this point?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 17 '06 #18

"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:66**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

The MyDataGrid control works fine on my machine. When I press the key, a
certain cell can be edited. Have you ever handle the key events of the
Textbox in that cell?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
No I have not, how would I do that?

Currently I have no ideal how to trouble shoot this problem, I have no idea
where the key press or key down event go to.
Aug 18 '06 #19
Peter,

In my idea to debug this you should break your control down.

Start with a new one and add first the members that don't work in your idea
and debug them than, that mostly brings you to a solution. If you do that,
than you make it as well possible to send that small part to the newsgroups
so that Kevin or somebody else including me, can try your problem as well.

Cor

"Peter" <pc*****@nospam.nospamschreef in bericht
news:ef**************@TK2MSFTNGP03.phx.gbl...
>
"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:66**************@TK2MSFTNGXA01.phx.gbl...
>Hi Peter,

The MyDataGrid control works fine on my machine. When I press the key, a
certain cell can be edited. Have you ever handle the key events of the
Textbox in that cell?

Kevin Yu
Microsoft Online Community Support
================================================= =

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

No I have not, how would I do that?

Currently I have no ideal how to trouble shoot this problem, I have no
idea where the key press or key down event go to.

Aug 18 '06 #20

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uk**************@TK2MSFTNGP02.phx.gbl...
Peter,

In my idea to debug this you should break your control down.

Start with a new one and add first the members that don't work in your
idea and debug them than, that mostly brings you to a solution. If you do
that, than you make it as well possible to send that small part to the
newsgroups so that Kevin or somebody else including me, can try your
problem as well.

Cor

"Peter" <pc*****@nospam.nospamschreef in bericht
news:ef**************@TK2MSFTNGP03.phx.gbl...
>>
"Kevin Yu [MSFT]" <v-****@online.microsoft.comwrote in message
news:66**************@TK2MSFTNGXA01.phx.gbl...
>>Hi Peter,

The MyDataGrid control works fine on my machine. When I press the key, a
certain cell can be edited. Have you ever handle the key events of the
Textbox in that cell?

Kevin Yu
Microsoft Online Community Support
================================================ ==

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

No I have not, how would I do that?

Currently I have no ideal how to trouble shoot this problem, I have no
idea where the key press or key down event go to.

I have found the problem, the problem was the DataGrid itself was set to
ReadOnly, the columns and ColumnStyles were set to ReadOnly = false, but I
guess that does not override the DataGrid readonly property, I though that
it did.

Thanks everyone for your help.
Aug 18 '06 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
4
by: Peter | last post by:
Hello Thanks for reviewing my question. I believe I read that a DataGrid can point to a collection but would like to know if you can point to an example. How does the DataGrid know what are the...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
1
by: Vagabond Software | last post by:
I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form,...
2
by: raymi | last post by:
Hi, I have a custom class that gets its properties dynamically from a database at runtime. Therefore I implemented the ICustomTypeDescriptor in this class and created a a custom...
1
by: Conawapa11 | last post by:
I'm having trouble figuring this problem out and every example out there deals with simple objects within a custom collection. Take this example: public class ComplexClass { private int id;...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
0
by: Gene Hubert | last post by:
I'm trying to implement a "floating textbox" in a datagrid and seeing some odd results. In my override for DataGridTextBoxColumn.Edit, I create a custom textbox that inherits from Textbox. I...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.