- 热门文章:
- · runat=server
- · 关于上下文(Context)/2(转MS)
- · 关于上下文(Context)/1(转MS)
- · 在.NET中使用静态变量来代替Application变量
- · ASP.NET窗体对话框的实现
- · 用.NET创建定时缓存
- · 将Session值储存于SQL Server中
- · ASP.NET中的事务处理和异常处理
- · ASP.NET Caching /2
- · 嘿,懒鬼!!其实MSDN阐述得真得不错哎,不知道你从哪来的资料
- · ASP.NET Caching /1
- · 绝对酷,如何解决asp.net中javascript脚本的问题(使用服务器控件执行客户端脚本)
上一篇:关于asp.net的代码重用 >>
Getting Datagrid Columns Keypress,Keyup, Keydown and other events to Fire(一个很好的东西)
@#copied this to a text program
@#After your form has a functioning datagrid and dataset,
@#do the following steps.
@#1) Name and declare each column as a textbox as follows
Friend WithEvents Column1 As TextBox
Friend WithEvents Column2 As TextBox
@#2) Create the tablestyles.
@#Here is the code microsoft gives to do just that.
@#(Again I did not write this part; its copied and @#pasted from MS!!)
Private Sub AddTables(ByVal myDataGrid As DataGrid, _
ByVal myDataSet As DataSet)
Dim t As DataTable
For Each t In myDataSet.Tables
Dim myGridTableStyle As DataGridTableStyle = New _
DataGridTableStyle()
myGridTableStyle.MappingName = t.TableName
myDataGrid.TableStyles.Add(myGridTableStyle)
@# Note that DataGridColumnStyle objects will
@# be created automatically for the first DataGridTableStyle
@# when you add it to the GridTableStylesCollection.*/
Next
End Sub
@#3) Add the next line of code in the Form Load Event
@#Use your own variable names for the datagrid and dataset)
AddTables(DataGrid1, DataSet1)
@#Creates the variable to identify object
Dim TempColumn As DataGridTextBoxColumn
@#Sets the variable to the datagrid column
TempColumn = DataGrid1.TableStyles(0).GridColumnStyles(0)
@#Set the column (textboxe actually) equal to the
@#temporary column you just created.
Column1 = TempColumn.TextBox
@#Repeat for each column you made. Notice the next line is
@#the same as the previous except it now identifies the
@#next column (one instead of zero) and the line after
@#that is the next column you created in step 1.
TempColumn = DataGrid1.TableStyles(0).GridColumnStyles(1)
Column2 = TempColumn.TextBox
@#4) Write the code for whatever event you want to fire. Notice
@#after you declared the variables withevents then they now appear
@#as a class in the drop down menu. Here is example to see the
@#keypress events fire for the two columns you identified.
Private Sub Column1_Keypress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles Column1.KeyPress
MsgBox("You have pressed the " & e.KeyChar)
End Sub
Private Sub Column2_Keypress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles Column2.KeyPress
MsgBox("You have pressed the " & e.KeyChar)
End Sub
下一篇:runat=server >>
相关文章:
- · 最佳ASP.NET编程习惯
- · 一次同时上传多个文件
- · 在datagrid中求和(vb.net,c#)
- · ASP.NET中利用SQLXML WEB服务访问XML数据(转)
- · 在DataGrid中经弹出窗口确认后执行操作(删除)。(附在DataGrid中修改,添加记录)详见代码!!
- · 在datagrid中放入一个DropDownList(忘了这个问题在那里看到的了CSDN or There)
- · 简单的动态加载用户控件的方法
- · 关于如何 确认删除的另外一个办法。
- · 掉掉注意了,如何动态加载用户控件(ascx)
- · 给大家一个新的加密方法,C#的。(国外的,只用于学习,支持中文)
- · TO feixr,DataGrid中的Radiobutton
- · 微软.NET战略和ASP.NET简介(1)
- · 微软.NET战略和ASP.NET简介(3)
- · 微软.NET战略和ASP.NET简介(2)
- · 验证控件介绍--RegularExpressionValidator
- · 验证控件介绍--RangeValidator
- · 验证控件介绍--CompareValidator
- · 验证控件介绍--RequiredFieldValidator
- · 解决分页的例子。使用DataSet绑定到DataList实现的。数据库使用我刚才贴的这个。
- · 配置Config.web
- · WebRequest Class
- · asp.net中使用静态变量
- · 利用HttpRequest登录到某个网站,然后获取网站信息的程序示例 [原创]
- · Creating DataGrid Templated Columns Dynamically - Part II(转自DotNetTips)
- · 用ASP.NET写你自己的代码生成器(2)。
- · 用ASP.NET写你自己的代码生成器(3)。
- · mark新官上任,转贴一个DataGrid(增加删除确认和新增记录功能),道贺:)
- · 一个datagrid 删除确认例子
- · 关于ASP.Net不能启动调试的官方解答
- · 在WEB窗体中如何转换页面和结束程序?
- · 关于ASP.Net写注册表权限问题的官方解决方法
- · 动态生成柱状图
- · 一个SDK里做聊天室的例子(2)
- · 网上下载和上传数据(一) Montaque(原作)
- · 一个SDK里做聊天室的例子(1)
- · 网上下载和上传数据(二) Montaque(原作)
- · 有空的时候看看,:)ASP.NET Page Templates
- · VB.NET开发互联网应用
