Question on Stats panels

itms

Member
Joined
Nov 5, 2018
Messages
10
Programming Experience
10+
Hi,
In Vb.Net I would simply create a procedure with the panel details, like size and the use it anywhere in the program. I have looked on the net and I can not find anything that works for C#, partly because they are given partial explanations.
I just need to add two or three status panels at the bottom of my form can someone explain this or point me to a good site.

Thank you
 
If you're saying, without actually saying, that you would add methods to a module in VB then you just add methods to a static class in C#. VB modules are the same as C# static classes once they are compiled. Modules and their design-time behaviour (no need to use Shared, no need to qualify members) is just maintaining an existing VB paradigm but they are still all .NET under the hood.

If that's not what you're saying, please say what you're saying.
 
Hi
And thanks for the reply. As I said I am little new to C#, ao I may not be expressing it right. It is not a module, I would put it in the procedure and be able to call it anywhere in the application. But aging if you can give a good site that would explain how to do it in C# I would appreciate it. But I will show you what I would have to do here in VB:
Private Sub CreateMyStatusBar()
' Display the first panel with a sunken border style.
panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken
' Initialize the text of the panel.
panel1.Text = "Ready..."
' Set the AutoSize property to use all remaining space on the StatusBar.
'panel1.AutoSize = StatusBarPanelAutoSize.Spring
panel1.AutoSize = StatusBarPanelAutoSize.Contents
' Display the second panel with a raised border style.
panel2.BorderStyle = StatusBarPanelBorderStyle.Raised
' Create ToolTip text that displays the time the application was started.
panel2.ToolTipText = "Started: " & System.DateTime.Now.ToShortTimeString()
' Set the text of the panel to the current date.
panel2.Text = System.DateTime.Today.ToLongDateString()
' Set the AutoSize property to size the panel to the size of the contents.
panel2.AutoSize = StatusBarPanelAutoSize.Contents
' Display panels in the StatusBar control.
statusBar1.ShowPanels = True
' Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1.Panels.Add(panel1)
statusBar1.Panels.Add(panel2)
' Add the StatusBar to the form.

End Sub
 
Um, that's just a method. You just write a method in C# too. In VB, a Function returns a value and a Sub does not but they are both methods. In C#, all methods are functions and you simply declare the return type as 'void' if you don't want to return anything.

It sounds like you don't know the basics of C# so you probably ought to follow the tutorial link in my signature below and go over that. You'll soon see that C# is actually very similar to VB.NET. There are syntax differences and some subtle variations, e.g. how a 'switch' works compared to a Select Case, but they are both .NET OO languages so the code is structured very, very similarly. For instance, for the body of that method, the only changes I can see that would be required is replacing '&' with '+' and appending a semicolon to each line.
 
Um, that's just a method. You just write a method in C# too. In VB, a Function returns a value and a Sub does not but they are both methods. In C#, all methods are functions and you simply declare the return type as 'void' if you don't want to return anything.

It sounds like you don't know the basics of C# so you probably ought to follow the tutorial link in my signature below and go over that. You'll soon see that C# is actually very similar to VB.NET. There are syntax differences and some subtle variations, e.g. how a 'switch' works compared to a Select Case, but they are both .NET OO languages so the code is structured very, very similarly. For instance, for the body of that method, the only changes I can see that would be required is replacing '&' with '+' and appending a semicolon to each line.

Okay thanks
 

Latest posts

Back
Top Bottom