10楼#
发布于:2004-12-29 20:18
<P>怎么没有回音阿,帝国总统是不是这几天没来,小弟急等着呢!!!</P>
|
|
11楼#
发布于:2004-12-30 09:41
<P>看看这段也许对你有帮助!!</P><P>This example uses the Edit method and the Updatable property in the context of a simple record editing application. The code also demonstrates how to use the CancelUpdate method to back out of making a change. In addition, the first time you change a record the code demonstrates the EditMode property. Note that the example determines the number of records by iterating through the Recordset. To try this example, paste the code into the Declarations section of a form containing a CommandButton control named Command1, a ComboBox named Combo1, a TextBox named Text1, and a Map named Map1 that has a MapLayer. For the CommandButton, set its Index property to 0 in the Control Properties dialog box to create a control array of one element, and then press F5. Choose a Field whose values you want to change. Enter the new value in the text box and press the Change button. You can iterate through the Recordset with the buttons named Next and Previous. </P><P>Private editbufr As Variant
Private recset As MapObjects2.Recordset Private TotalRecs As Integer</P><P>Private Sub Combo1_Click() Text1.Text = recset.Fields(Combo1.List(Combo1.ListIndex)).Value End Sub</P><P>Private Sub Command1_Click(Index As Integer) Static recnum</P><P> With recset.Fields(Combo1.List(Combo1.ListIndex)) Select Case Index Case 0 'Next If recnum < TotalRecs Then recset.MoveNext Text1.Text = .Value recnum = recnum + 1</P><P> Command1(1).Enabled = True If recnum = TotalRecs - 1 Then Command1(0).Enabled = False Else Command1(0).Enabled = True End If Map1.TrackingLayer.Refresh True End If Case 1 'Previous If recnum > 0 Then recset.MovePrevious Text1.Text = .Value recnum = recnum - 1 Command1(0).Enabled = True If recnum = 0 Then Command1(1).Enabled = False</P><P> Else Command1(1).Enabled = True End If Map1.TrackingLayer.Refresh True End If Case 2 'Change editbufr = .Value recset.Edit .Value = Text1.Text resp$ = MsgBox("Are you sure you want to change the value?", vbYesNo + vbInformation, "MapObjects") If resp$ = vbYes Then GetEditMode 'demonstrates EditMode property recset.Update GetEditMode Else</P><P> recset.CancelUpdate Text1.Text = editbufr End If recset.StopEditing End Select End With End Sub</P><P>Sub GetEditMode() Static Demonstrated As Integer If Demonstrated < 2 Then Select Case recset.EditMode Case 0 Msg$ = "No editing operation is in progress." Button$ = vbInformation Case 1 Msg$ = "Edit in progress" Button$ = vbExclamation Case 2 Msg$ = "AddNew method has been invoked."</P><P> Button$ = vbExclamation End Select MsgBox Msg$, Button$, "MapObjects" End If Demonstrated = Demonstrated + 1 End Sub</P><P>Private Sub Form_Load() For i = 1 To 2 ' Create two more instances of Command1. ' Set the location of the new option button. Load Command1(i) Command1(i).Top = Command1(i - 1).Top + Command1(0).Height + 40 Command1(i).Visible = True Next i</P><P> Command1(0).Caption = "Next" Command1(1).Caption = "Previous"</P><P> Command1(2).Caption = "Change"</P><P> Set recset = Map1.Layers(0).Records For Each f In recset.Fields Combo1.AddItem f.Name Next f Combo1.ListIndex = 0 'count the number of records ctr = 0 Do While Not recset.EOF TotalRecs = TotalRecs + 1 recset.MoveNext Loop</P><P> recset.MoveFirst Text1.Text = recset.Fields(Combo1.List(Combo1.ListIndex)).Value Command1(1).Enabled = False If Not recset.Updatable Then Command1(2).Enabled = False</P><P> End If End Sub</P><P>Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Stdole.OLE_HANDLE) Map1.FlashShape recset.Fields("Shape").Value, 3 End Sub</P><P> 我也遇到你类似的问题,把这段代码改改,就行了。重要的是用表中的关键字确定修改那条记录。</P><img src="images/post/smile/dvbbs/em08.gif" />[<img src="images/post/smile/dvbbs/em07.gif" /> |
|
12楼#
发布于:2004-12-30 14:37
<P>谢谢你老兄,关键是我还是搞不清楚怎样用表中的关键字确定那条记录,比如说,我点击了地图上的某一段,然后出现了相应的属性,我在对属性进行更改的时候,怎样识别要修改的纪录是刚才点击的那一段所对应的纪录。这个问题困扰我很久了,希望高手给指点一下。不知道各位大侠明白我的意思了吗?</P>
|
|
13楼#
发布于:2004-12-31 09:33
麻烦帝国总统一下,请告诉一个解决的办法,还有各位高手。本人在焦急的等待。
|
|
14楼#
发布于:2005-01-07 12:10
<img src="images/post/smile/dvbbs/em02.gif" />
|
|
15楼#
发布于:2005-01-07 20:42
<img src="http://www.gisempire.com/bbs/Skins/default/topicface/face3.gif"><img src="http://www.gisempire.com/bbs/Skins/default/topicface/face6.gif">楼上能否解决大数量属性纪录浏览?
|
|
16楼#
发布于:2005-05-04 12:13
<P>总统,我按照你方法对我的图层属性进行修改如下:</P>
<P>Public Sub addFldResult(Rs As ADODB.Recordset, lyRs As MapObjects2.Recordset) If Not Rs.BOF Then Rs.MoveFirst End If Do While (Not Rs.EOF) lyRs.MoveFirst Do While (Not lyRs.EOF) If Rs.Fields("图元名").Value = lyRs.Fields("name").ValueAsString Then lyRs.Edit lyRs.Fields("Result").Value = Rs.Fields("结果").Value lyRs.Update lyRs.StopEditing MsgBox Rs.Fields("结果").Value MsgBox lyRs.Fields("Result").ValueAsString Exit Do End If lyRs.MoveNext Loop Rs.MoveNext Loop End Sub</P> <P>可为什么我的图层属性并没有改变,两个msgbox 出来的结果不一样,打开属性数据表,也没有改变,急知道,谢谢</P> |
|
17楼#
发布于:2005-05-15 10:26
<P>楼上的大大想必是已经可以开启属性数据表了</P><P>小弟目前遇到不知如何开启属性数据表的问题</P><P>不知道楼上的大大是否可以提供一点范例教学啊</P><P>感谢</P>
|
|
18楼#
发布于:2005-05-16 17:05
<P>在点击那个段的时候,你可以从shapefile文件中读取那个ID(xx)号啊,然后修改属性记录,如果需要保存修改的记录,可以 update ,在where ID="xx",这样可以不?</P>
|
|
|
上一页
下一页