以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]文本框双击赋值问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=63132)

--  作者:cqlwsam
--  发布时间:2015/1/14 15:35:00
--  [求助]文本框双击赋值问题

资料文本框通过双击得到一个文件列表,选择文件,并把文件名赋值给资料文本框。相应的目录下也已经存在该文件,但文本框中无内容,不知道为什么?谢谢!

代码如下:
Dim frm As WinForm.Form= e.Form
Dim txt1 As String = frm.Controls("TextBox3") .value
Dim txt2 As String = frm.controls("DropBox1").value
Dim txt3 As String = frm.Controls("TextBox2").value
If txt1="" Then
    MessageBox.Show("无患者资料名称,无法保存患者资料!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
Else
    If txt2<>"" AndAlso txt3<>"" Then
        Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
        If txt2="二维照片" Then
            dlg.Filter= "照片文件|*.bmp;*.gif;*.jpg;*.png;*.tif;*.wmf;*.tiff;*.pcx;*.tga;*.exif;*.fpx;*.svg;*.psd;*.cdr;*.pcd;*.dxf;*.ufo;*.eps;*.ai;*.raw" \'设置筛选器
        Else If  txt2="视频资料" Then
            dlg.Filter= "视频资料|*.avi;*.wmv;*.wmp;*.wm;*.asf;*.mpg;*.mpeg;*.mpe;*.m1v;*.m2v;*.mpv2;*.mp2v;*.dat;*.ts;*.tp;*.tpr;*.trp;*.vob;*.ifo;*.ogm;*.ogv;*.mp4;*.m4v;*.m4p;*.m4b;*.3gp;*.3gpp;*.3g2;*.3gp2;*.mkv;*.rm;*.ram;*.rmvb;*.rpm;*.flv;*.swf;*.mov;*.qt;*.amr;*.nsv;*.dpg;*.m2ts;*.m2t;*.mts;*.dvr-ms;*.k3g;*.skm;*.evo;*.nsr;*.amv;*.divx;*.webm;*.wtv;*.f4v" \'设置筛选器
        Else If txt2="音频资料" Then
            dlg.Filter= "音频资料|*.mp3;*.wav;*.wma;*.mpa;*.mp2;*.m1a;*.m2a;*.ogg;*.m4a;*.aac;*.mka;*.ra;*.flac;*.ape;*.mpc;*.Mod;*.ac3;*.eac3;*.dts;*.dtshd;*.wv;*.tak" \'设置筛选器
        Else If txt2="文本资料" Then
            If  txt3="文字资料" Then
                dlg.Filter= "文字资料|*.doc;*.txt;*.docx;*.docm" \'设置筛选器
            Else If txt3="PDF资料" Then
                dlg.Filter= "PDF资料|*.pdf" \'设置筛选器
            Else If txt3="表格资料" Then
                dlg.Filter= "表格资料|*.xls" \'设置筛选器
            End If
        End If
        If dlg.ShowDialog = DialogResult.OK Then
            Dim ext As String = dlg.FileName.SubString(dlg.FileName.LastIndexof(".") + 1) \'获得文件后缀名
            Dim txt4 As String = ProjectPath & "temp\\" & txt1 & "." & ext
            e.Form.controls("TextBox4").value=txt4
            If filesys.FileExists(txt4) Then
                Dim Result As DialogResult
                Result = MessageBox.Show("存在同名的辅助资料文件,覆盖它吗?","提醒!!",MessageBoxButtons.OKCancel, MessageBoxIcon.warning )
                If Result = DialogResult.Ok Then
                    filesys.CopyFile(dlg.FileName,txt4,True)                   
                Else
                    Return
                End If
            Else
                filesys.CopyFile(dlg.FileName,txt4)
            End If
            Tables("辅助资料录入_table2").save()
            Tables("辅助资料录入_table2").Refresh
        End If
    Else
        MessageBox.Show("无资料类型或资料亚类,无法确定您需添加的文件类型!!","提示!!",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If
End If

[此贴子已经被作者于2015-1-14 16:25:32编辑过]

--  作者:Bin
--  发布时间:2015/1/14 15:37:00
--  
你文本框如果绑定了列,就不应该为文本框赋值,而是直接为该列赋值
--  作者:有点甜
--  发布时间:2015/1/14 15:52:00
--  

 看看

 

http://www.foxtable.com/help/topics/2436.htm

 


--  作者:cqlwsam
--  发布时间:2015/1/14 15:53:00
--  
资料文本框通过双击获取的资料是暂时的,通过预览确认就是选择的文件后,单击确认后保存在指定的目录中。所以整得有点复杂。
--  作者:Bin
--  发布时间:2015/1/14 15:55:00
--  
如果是绑定了列,就参考 2 , 3楼
--  作者:cqlwsam
--  发布时间:2015/1/14 15:59:00
--  
知道了。我改改代码。谢谢!
--  作者:cqlwsam
--  发布时间:2015/1/14 16:21:00
--  
就是这样。直接赋值给列就可以了。谢谢!