Hi,
As you know that, a MSFlexGrid is read only, and I want it to be editable as a textbox. So I add a textbox, called text1, to the form which also has a MSFelxGrid called Grid1. Code like this:
gRow and gCol are public variable in the form class.
Private Sub UpDataGrid_KeyPressEvent(ByVal sender As System.Object, ByVal e As AxMSFlexGridLib.DMSFlexGridEvents_KeyPressEvent) Handles Grid1.KeyPressEvent 'Move the text box to the current grid cell: Text1.Top = Grid1.CellTop + Grid1.Top Text1.Left = Grid1.CellLeft + Grid1.Left 'Save the position of the grids Row and Col for later: gRow = Grid1.Row gCol = Grid1.Col 'Make text box same size as current grid cell: Text1.Width = Grid1.CellWidth Text1.Height = Grid1.CellHeight 'Transfer the grid cell text: Text1.Text = Grid1.Text 'Show the text box: Text1.Visible = True End Sub
Private Sub Text1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Text1.KeyPress Text1.Focus() End Sub
Private Sub Text1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.Leave Dim tmpRow As Integer Dim tmpCol As Integer 'Save current settings of Grid Row and col.This is neededonly 'if the focus is set somewhere else in the Grid. tmpRow = Grid1.Row tmpCol = Grid1.Col 'Set Row and Col back to what they were before LostFocus Grid1.Row = gRow Grid1.Col = gCol Grid1.Text = Text1.Text 'Transfer text back to grid. ' Return row and Col contents: Grid1.Row = tmpRow Grid1.Col = tmpCol End Sub
Question:
1) How can I change the ZOrder of Text1 and Grid1?
In VB6 we can use text1.Zorder(0) to implement this, but how it do in VB2005?
2) In Text1_KeyPress(…), how can visit or monitor our keyboard?
3) If there are more than 1 textbox, how can I kown which one is text1, from parameter "sender"?
Thank you.
dp.SyntaxHighlighter.ClipboardSwf = ‘/dp.SyntaxHighlighter/Scripts/clipboard.swf’
dp.SyntaxHighlighter.HighlightAll(’96894b07e16047ccb1ed155b782330d8′)
dp.SyntaxHighlighter.HighlightAll(‘ce82a065892a46deb43d6bd99f1ad2b5′)
dp.SyntaxHighlighter.HighlightAll(‘c215bd69ed464142a18e1beb24781c3f’)
Similar:
- Context Menu with webBrowser hi guys i need some help. I have created a web browser using VB.NET .NET Frameworks 4.0. The following code is what i am...
- Factorial using BigInteger Imports System.Numerics 'have to add reference Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As Integer...
- Simple “open cd tray” app not working one one computer I have a simple executor that when clicked, opens the CD tray. Public Class Form1 Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _ (ByVal...
- Creating a new record (Using MSDN example) Hi, I have recently used an MSDN video session to create two forms. The first for lists my dataset in a datagridview. The second form...
- Obout "onCallbackError" problem Hi… I’m using the obout grid control in c# and not to sure how to throw an error from the code behind! I am catching...