使用vs2010编写VB.NET程序,想在写日志的时候,写下当时的行号。苦于未找到方法,请大神告知。
Dim st as System.Diagnostics.StackTrace = New System.Diagnostics.StackTrace(1, True)
MsgBox(st.GetFrame(0).GetFileLineNumber())
如果问题解决,麻烦点下我回答右边的采纳,谢谢
可能不是很理解你的问题,你说的是日志文件的行号的话
File.ReadAllLines(你的日志文件名).Count() 就是日志文件当前的行数,+1就是你接下来写的那行的行号。
Me.DataGridView1.CurrentCell.RowIndex 可以获取当前被选中的行号
可以定义一个静态全局的变量index
然后在SelectionChanged事件中为index=Me.DataGridView1.CurrentCell.RowIndex
这样就可以动态的在其他地方使用当前被选中的行号index了
me.DataGridView1 .SelectedRows (0).Cells(2).Value 或者 me.DataGridView1 .SelectedRows (0).Cells("cloumns_name").Value 可以获取被选中行号中指定单元格的值