|
hi all,
I dynamically create buttons on main_form, then in a module (functions) i try to access this controls by setting an focus to one of them.
when i try to access with "index = Frm_Main.CtrlFocus" it doesnt work becouse number of controls is zero since this frm_main is new instance i guess?!
Does anyone know how to fix this, and if there is a better way?
Thanks
greg
Public Class Frm_Main
Dim WithEvents BtnOperate As New OpenNETCF.Windows.Forms.Button2
Private Sub Frm_Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BtnOperate.Location = New System.Drawing.Point(20, 20)
Me.BtnOperate.Size = New System.Drawing.Size(150, 150)
Me.BtnOperate.TabIndex = 0
Me.Controls.Add(Me.BtnOperate)
Me.BtnOperate.BackgroundImage = b
Me.BtnTest2.Location = New System.Drawing.Point(340, 20)
Me.BtnTest2.Size = New System.Drawing.Size(150, 150)
Me.BtnTest2.TabIndex = 2
Me.Controls.Add(Me.BtnTest2)
Me.BtnTest2.BackgroundImage = b
End Sub
Public Property CtrlFocus() As Integer
Get
Dim i As Integer = Me.Controls.Count
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Focused Then
Return ctrl.TabIndex
End If
Next
End Get
Set(ByVal value As Integer)
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.TabIndex = value Then
ctrl.Focus()
End If
Next
End Set
End Property
End Class
Public Class Functions
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SP1.DataReceived
BytesToRead = SP1.BytesToRead
Dim buffer(BytesToRead - 1) As Byte
SP1.Read(buffer, 0, BytesToRead)
message = message + System.Text.Encoding.Default.GetString(buffer, 0, BytesToRead)
SP1.DiscardInBuffer()
If message.IndexOf(Chr(3)) > -1 Then
Dim STX As Integer = message.IndexOf(Chr(2))
If message(STX + 1) = "K" Then
Dim index As Integer
Select Case message(STX + 2)
Case "U"
index = Frm_Main.CtrlFocus
index = (index + 4) Mod 8
Frm_Main.CtrlFocus = index
End Select
End If
End Sub
|
|
|
|
|
Stop spamming the forums!
-- modified at 10:52 Tuesday 8th May, 2007
This was originally a response to a message that has since been deleted.
|
|
|
|
|
I have created one application in VB.Net.
I want to create one shortcut for it
like Window key+E (for Explorer).
How can i do that?
|
|
|
|
|
I'll need some clarification.
Are you looking for a shortcut like from you own desktop or are you looking for how to create a shortcut to your application from within a distribution set? So as to automatically create a shortcut on a users PC desktop when installing your app.
Jelle
|
|
|
|
|
automatically create a shortcut on a users PC desktop when installing app.
|
|
|
|
|
You will need to use Win32 API.
here are functions you can use...
<br />
[DllImport("USER32.dll")]<br />
public static extern bool RegisterHotKey(IntPtr hWnd,<br />
int id, int fsModifiers, int vlc);<br />
<br />
[DllImport("USER32.dll")]<br />
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);<br />
"If our Mind can, the Program can !!"
|
|
|
|
|
Are you going to check whether the user is using that shortcut for something else first? Hijacking users' control over their own machines is not a way to create good will towards your app.
|
|
|
|
|
i have a datagridview and two table of record, one is parent and another is child table.
so, how can i binding the record to the datagrid so the data can nested?
Regards,
Chee ken
|
|
|
|
|
Hi,
Currently I am designing a tool in VB.Net for automation of a datawarehousing tool called DataStage. I have to run this tool through command prompt in VB.Net. The command is
dsjobs –server xx.xxx.xx.xx –user abcd –password wxyz –run
[Project] [Job] [List of parameters]
Application path is the location where datastage client is installed in the local machine.
Other attributes like:
-lparam: Give the list of parameters for a particular job
-ljobs: List all the jobs in a particular project
-lprojects: List all the projects available in the server
-run: To run a job
-stop: To stop a job etc….
Now can anyone help me how to put these in VB.Net and how to fetch the results of these commands. Because based on the results of these commands I have to create dynamic text boxes.
It looks complicated, but can anyone who knows this help me out ?
Thanks in advance.
-- modified at 4:37 Tuesday 8th May, 2007
|
|
|
|
|
Process.Start is basically shellexecute, you can pass your parameters through there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
how to connect the vb.net windows application with ms access?
|
|
|
|
|
please tell us your exact problem , and where you are stuck so we can help you
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
If you type this question into google, you will get tons of hits.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
What is the best way to make my program in several languages? Should I create text files that contain label text, window titles, messagebox texts in different langugaes or what do you recommend?
|
|
|
|
|
Store all your strings in the application resources and ship different resource files.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I a bit of a beginner. How do you do this in practice? Could you give me an example? Let's say label1.Text is in Finnish "Jotain" and in English "Something".
|
|
|
|
|
re infecta wrote: Should I create text files that contain label text, window titles, messagebox texts in different langugaes or what do you recommend?
That is how I would do it, except I would use an Ini file. Using an Ini file would make the process of organizing text between controls and dialogs a lot easier.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
OK, I have never used INI files. Could you give me some practical example or reference in web? Thanks?
|
|
|
|
|
The way I said to do it, is the way that the framework fully supports.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Try this article: INI File Class.
If you need further help, just search CodeProject for "Ini Files".
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
You mean to tell me that you're going to go through the hassel of reading the text file and changing the Text property of every control in your application yourself? Why not just let the Framework do it for you??
|
|
|
|
|
Dave Kreskowiak wrote: Why not just let the Framework do it for you??
I hate the way the .NET Framework handles stuff like that, I prefer to do it the old fashioned way. Personal preference.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
It handles it much better than you do. How about a case where your application has a couple dozen forms and a couple hundred controls? I bet your method is pretty slow.
|
|
|
|
|
NSIS and many others manage.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
re infecta wrote: Could you give me some practical example or reference in web?
Speaking in terms of practicality, don't listen to MatrixCoder. Use the resource files as Christian suggests, because practically speaking you'll find more tools to help you with those (in regards to editing for multi-language that is), and INI files are a tad slower anyway.
|
|
|
|