获取标记某些属性的所有属性(Get all properties which marked certain attribute)
那里有课堂和物业。 某些属性可以被标记为属性(这是我的
LocalizedDisplayName
从DisplayNameAttribute
继承)。 这是获取类的所有属性的方法:private void FillAttribute() { Type type = typeof (NormDoc); PropertyInfo[] propertyInfos = type.GetProperties(); foreach (var propertyInfo in propertyInfos) { ... } }
我想在列表框中添加标记
LocalizedDisplayName
的类的属性,并在列表框中显示属性的值。 我该怎么做?编辑
这是LocalizedDisplayNameAttribute:public class LocalizedDisplayNameAttribute : DisplayNameAttribute { public LocalizedDisplayNameAttribute(string resourceId) : base(GetMessageFromResource(resourceId)) { } private static string GetMessageFromResource(string resourceId) { var test =Thread.CurrentThread.CurrentCulture; ResourceManager manager = new ResourceManager("EArchive.Data.Resources.DataResource", Assembly.GetExecutingAssembly()); return manager.GetString(resourceId); } }
我想从资源文件获取字符串。 谢谢。
I have class and properties in there. Some properties can be marked attribute (it's my
LocalizedDisplayName
inherits fromDisplayNameAttribute
). This is method for get all properties of class:private void FillAttribute() { Type type = typeof (NormDoc); PropertyInfo[] propertyInfos = type.GetProperties(); foreach (var propertyInfo in propertyInfos) { ... } }
I want to add properties of class in the listbox which marked
LocalizedDisplayName
and display value of attribute in the listbox. How can I do this?EDIT
This is LocalizedDisplayNameAttribute:public class LocalizedDisplayNameAttribute : DisplayNameAttribute { public LocalizedDisplayNameAttribute(string resourceId) : base(GetMessageFromResource(resourceId)) { } private static string GetMessageFromResource(string resourceId) { var test =Thread.CurrentThread.CurrentCulture; ResourceManager manager = new ResourceManager("EArchive.Data.Resources.DataResource", Assembly.GetExecutingAssembly()); return manager.GetString(resourceId); } }
I want to get string from resource file. Thanks.
原文:https://stackoverflow.com/questions/7305787
最满意答案
使用recordsetclone:
Dim rs As DAO.Recordset With Me![Selection subform1].Form Set rs = .RecordsetClone rs.AddNew rs![Module Code].Value = Sem1select1.Value rs![Semester 1 Credits].Value = Sem1sel1cred.Value rs.Update ' Move to new record: .Bookmark = rs.Bookmark Set rs = Nothing End With
Use the recordsetclone:
Dim rs As DAO.Recordset With Me![Selection subform1].Form Set rs = .RecordsetClone rs.AddNew rs![Module Code].Value = Sem1select1.Value rs![Semester 1 Credits].Value = Sem1sel1cred.Value rs.Update ' Move to new record: .Bookmark = rs.Bookmark Set rs = Nothing End With
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
linux 结构体命名规则[2024-03-18]
record -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
使用recordsetclone: Dim rs As DAO.Recordset With Me![Selection subform1].Form Set rs = .RecordsetClone rs.AddNew rs![Module Code].Value = Sem1select1.Value rs![Semester 1 Credits].Value = Sem1sel1cred.Value rs.Update ' Move t ...
-
MS Access - 使用表单添加新记录并将信息添加到子表单(MS Access - Add new record using form and add info to subform)[2022-02-12]
是。 这将 - 在主窗体中 - 返回子窗体的当前ID: Dim SubId As Long SubId = Me!NameOfYourSubformControl.Form!ID.Value Yes. This will - in the main form - return the current ID of the subform: Dim SubId As Long SubId = Me!NameOfYourSubformControl.Form!ID.Value -
从子表单记录审核日志(Record audit log from subform)[2021-05-25]
只需在你的写代码中放置一个限定符,在Type或Name或你拥有的任何东西上; If ctl.Type <> acCheckBox thenend if If FieldName <> "UnwantedCheckBox" then end if 我在每种形式中使用此代码进行完全控制; https://stackoverflow.com/a/27737258/4411380 Just put a qualifier in your write ... -
在主窗体中的组合框字段上使用On Change并输入: subFormname.SetFocus DoCmd.GoToRecord , , acNewRec 我一直在努力,想出了这种语法。 如果你有更好的东西,请告诉我。 Use On Change on combo box field in main form and enter: subFormname.SetFocus DoCmd.GoToRecord , , acNewRec I kept trying and came up with this ...
-
子窗体仅显示单个记录(Subform only shows single record)[2022-12-19]
主表单应该没有记录源,并且应该没有链接标准。 过滤器控件的更新后事件应该更新子窗体的过滤器(如CodeSlave的代码那样),你可以分配子窗体的记录源(我倾向于选择后者,因为我不必担心所有过滤器带来的问题)。 我过去曾多次这样做过,但通常没有使用子表单。 我不喜欢数据表并使用连续表单,并将过滤控件放在表单的标题中。 然后,您可以避免引用子窗体控件的困难(尽管这很简单,因为您可以使用With / End With块,如Praesagus的帖子中所示)。 关键是您希望主窗体UNBOUND,并且您希望控件放在条件 ... -
MS Access - 基于相同表格但不同记录的表单和子表单(MS Access - Form and subform based on same table, but different record)[2021-08-12]
我不知道为什么Access陷入困境,因为我总是自己使用VBA和纯SQL做事,而且从不依赖Access内置功能,这通常更有效,并避免像你遇到的那样的“错误”。 所以,如果你想像我一样编码,这是我可以提出的解决方法。 开始删除表单上的父/子(如果您愿意,主/从)关系。 在主窗体的current事件中,添加以下代码: dim strSQL as string ' adapt the following SQL where needed : ' - adapt table name ' - Replace * w ... -
当你关闭Form2时,你是否重新伪造Form1? 如果是这样,那么你必须在该重新查询之前将当前记录的ID值存储在Form1中,然后在重新查询之后使用FindFirst来找到它: Dim intID As Integer intID = Forms("Form1").YourIDField ' requery, or whatever, here Dim rst As DAO.Recordset Set rst = Me.RecordsetClone rst.FindFirst "YourIDField=" ...