DataGrid自定义类 [英] DataGrid custom class

查看:73
本文介绍了DataGrid自定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类,但我想在

中创建一个我的DataGrid可编辑的列,我该怎么做?当我使用这个类没有

这些列是可编辑的,即使我将ReadOnly属性设置为false?


谢谢

彼得

''--------------------------------------- ----------

公共类MyDataGrid

继承DataGrid


私有_processVars作为ProcessVariables

Private _sortDir As String =" NONE"

Private _sortVar As String =" NONE"


受保护的覆盖Sub OnMouseDown(ByVal e作为

System.Windows.Forms.MouseEventArgs)


Dim pt As New Point(eX,eY)


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


如果hit.Type = HitTestType.ColumnHeader AndAlso(hit.Column = 1或

hit.Column = 2)然后

Dim col As String =

Me.TableStyles(0).GridColumnStyles(hit.Column).Map pingName


如果Me._sortVar.Equals(col)那么

如果hit.Column = 1那么

如果Me._sortDir.Equals(" ASC")那么

Me._sortDir =" DESC"

ElseIf Me._sortDir =" DESC"然后

Me._sortDir =" NONE"

Else

Me._sortDir =" ASC"

结束如果

否则

如果Me._sortDir.Equals(" ASC")那么

Me._sortDir =" DESC"

否则

Me._sortDir =" ASC"

结束如果

Else

Me._sortDir =" DESC"

Me._sortVar = col

结束如果


Me._processVars.SortGrid(Me,Me._sortDir,Me._sortVar)

返回''不要调用baseclass


结束If


MyBase.OnMouseDown(e)


End Sub''OnMouseDown

Public WriteOnly Property ProcessVars()As ProcessVariables

Set(ByVal Value As ProcessVariables)

Me._processVars = Value

结束集

结束属性

结束类''MyDataGrid

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

推荐答案

这应该可以解决问题:
http://www.syncfusion.com/FAQ/Window ... 44c.aspx#q758q


(5.18)
This should do the trick:
http://www.syncfusion.com/FAQ/Window...44c.aspx#q758q

(5.18)


Pieter给了我们一个很好的样本来做这个伎俩。您可以使所有其他

列不可编辑,以使一列可编辑。


Kevin Yu

Microsoft在线社区支持


======================================= ===========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。

注意:MSDN托管新闻组支持服务适用于非紧急问题

,可以在1个工作日内收到社区或Microsoft支持工程师的初步回复。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========


(此帖子按原样提供,不作任何保证,并且不授予

权利。 )

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.)


嗨彼得,


我想知道这个问题是否已经解决。我有什么可以帮助的吗?我还在监视它。如果您有任何疑问,请随时在社区中发布。


Kevin Yu

Microsoft在线社区支持

========================================== ========


(此帖子按原样提供,不作任何保证,并且不授予

权利。)

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.)


这篇关于DataGrid自定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆