|
I am trying to put a header on each of my columns in my data grid. I have the columns already there, but with a different name from when I made the data relations. For example on column one it has "fldEmployeeId". I just want "Employee ID". I am getting an error while trying to run it. It is telling me that
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dllAdditional information: Index was out of range. Must be non-negative and less than the size of the collection.
The error is on the first line in this part of the code.
What am I doing wrong? I have a total of 6 columns. Any suggestions.
dgPayrollInfo.GridColumnStyles(0).HeaderText = "Employee ID"
dgPayrollInfo.GridColumnStyles(0).Alignment = HorizontalAlignment.Center
dgPayrollInfo.GridColumnStyles(1).HeaderText = "Payroll ID"
dgPayrollInfo.GridColumnStyles(1).Alignment = HorizontalAlignment.Center
dgPayrollInfo.GridColumnStyles(2).HeaderText = "Pay Date"
dgPayrollInfo.GridColumnStyles(2).Alignment = HorizontalAlignment.Center
dgPayrollInfo.GridColumnStyles(3).HeaderText = "Gross Pay"
dgPayrollInfo.GridColumnStyles(3).Alignment = HorizontalAlignment.Right
dgPayrollInfo.GridColumnStyles(4).HeaderText = "Withholding"
dgPayrollInfo.GridColumnStyles(4).Alignment = HorizontalAlignment.Right
dgPayrollInfo.GridColumnStyles(5).HeaderText = "Net Pay"
dgPayrollInfo.GridColumnStyles(5).Alignment = HorizontalAlignment.Right
Thank you,
ibok23
|
|
|
|
|
You need to create the GridColumnStyle first, then added it to the GridColumStylesCollection. Just indexing a GridColumnStyleCollection, like your doing, will not create a new column.
Dim newGridColumnStyle As New GridColumnStyle
newGridColumnStyle.HeaderText = "Employee ID"
newGridColumnStyle.Alignment = HorizontalAlignment.Center
dgPayrollInfo.GridColumnStyles.Add( newGridColumStyle )
.
.
.
RageInTheMachine9532
|
|
|
|
|
Dim GridTableStyle1 As New DataGridTableStyle()<br />
GridTableStyle1.MappingName = "Customer"<br />
'Customer is the name of the table in the dataset<br />
<br />
Dim GridColStyle1 As New DataGridTextBoxColumn()<br />
With GridColStyle1<br />
.HeaderText = "ID"<br />
.MappingName = "CustID"<br />
<br />
End With<br />
GridTableStyle1.GridColumnStyles.Add(GridColStyle1)<br />
<br />
MyDataGrid.TableStyles.Add(GridTableStyle1)
|
|
|
|
|
I am finishing up the deployment package for my first VB.NET application. Is there a way I can add the VB redistributable to my startup project so that it will automatically install before my application, if it isn't already on the target machine?
Thanks!
|
|
|
|
|
No because your VB.NET app won't even launch without the .NET Framework already installed.
You'll have to install the framework during your app's installation. Search CodeProject and www.GotDotNet.com for articles on Bootstrapping Setup.
RageInTheMachine9532
|
|
|
|
|
OK - I downloaded the dotnetfx.exe file and the Bootstrap example. I think I have those correct, but in one of the MSDN article on this, it says that "The following line of code launches a silent install of Dotnetfx.exe:
dotnetfx.exe /q:a /c:"install /l /q"
Nowhere does it say where this code goes, or how it is called. This is my first VB.NET applicationm and things like this are very frustrating. Can anyone tell me how to implement this command? I am trying to put this application on a CD snd set it up so that the install begins automatically when the CD is inserted in the target computer, or the CD is inserted and the user clicks on "Startup" in the "Run" dialog box.
Thanks!
|
|
|
|
|
That command goes inside the Bootstrap sample. i haven't seen the code for it yet, mainly because I've deployed the .NET Framework to all of my client machines so I dont have to worry about this problem...
I'll check into the bootstrap sample and let you know...
RageInTheMachine9532
|
|
|
|
|
OK. After looking at the docs for the Setup.exe bootstrap sample, you don't have to do anything with that command. It just said that that is the command that will be used to start the setup for the .NET Framework. All you need to do is create a Settings.ini file with the appropriate information in it and make sure it is in the same directory as the Setup.exe file:
CD Root Directory
Setup.exe
Settings.ini
dotnetfx.exe
myapp.msi
any other files your app needs...
RageInTheMachine9532
|
|
|
|
|
I tried that and the .NET Framework installed, but the innstall was visible to the user. Isn't there a way to have .NET Framework install in the background?
Thanks!
|
|
|
|
|
If you are using .NET framework 1.1 then download and use the following plugin for VS.NET from Microsoft. Its cool and simple. Any doubts please feel free to ask, I have used this for Windows, Web application installation
Using Visual Studio .NET 2003 to Redistribute the .NET Framework[^]
He who controls others may be powerful, But he who has mastered himself is mightier still.
|
|
|
|
|
Dim chrEachCharOut() As String =
Split(txtAcctInXor.Text, "^")
For Each chrSet In chrEachCharOut
‘do stuff here
Next
txtAcctInXor.Text contains 14^7^26^90
After the Split, chrEachCharOut has a length of 5. I was expecting 3 since the split returns a zero-based array containing the substrings. Why is the length 5? If I step thru the code I see 14, then 7, then 26, then 90, then I receive the following error -'System.InvalidCastException' occurred …”….Additional information: Cast from string "" to type 'Integer' is not valid. I only want the information between the ^ to be returned to me. Any ideas?
All help appreciated!
|
|
|
|
|
Hi nug. Are you sure that txtAcctInXor.Text contains "14^7^26^90" and not "14^7^26^90^" with an extra "^" at the end?
|
|
|
|
|
Sorry, there is an extra ^ at the end.
|
|
|
|
|
It happens to the best of us
|
|
|
|
|
Hi All,
I am writting a CRC program (for Windows use) now for my project. But, the code not working so far. Any of you have a sample code for me?
Code in VB.Net is my preference.
Thanks in advance!
FG
|
|
|
|
|
Your going to have to post a more specific question!
What's not working? What are you having a problem with?
RageInTheMachine9532
|
|
|
|
|
Hi,
The whole programming can't run. When I run, it show me some header file cant work.
Please advise.
Thanks.
|
|
|
|
|
You can do better than that! What's the EXACT message the compile spits out and what does the code look like around that line. Without it, there is nothing we can do to help you with the problem.
RageInTheMachine9532
|
|
|
|
|
Is there a way to access the programs that are built into the add/remove program in control panel. I want to be able to write a vb program or script that removes the .net framework silently. Is it possibly to access what happens when you go to the control panel and click add/remove programmically?
thanks in advance
lep
|
|
|
|
|
The easy way to uninstall an app is to use the System.Management classes and WMI. You would be using the Win32_Product class. The downside is it won't do a silent uninstall.
The hard way would be to use the Windows Installer API's. The documentation starts here[^]. The upside of using this method is that you get total control of how the uninstall behaves. The down side is it's complexity.
I hope your doing in in VB6 and not VB.NET. Trying to write a program in VB.NET to uninstall the .NET Framework is never going to work since you cannot uninstall something that your program absolutely needs in order to run...
RageInTheMachine9532
|
|
|
|
|
Hi all..
Can anybody there guide me regarding how to implement multilingua support in Visual Basic 6?
Basically, i m trying to build an application in which i could give different language options, and depending upon selected language option i would be able to change my application layout(in terms of language).
NOTE:
smaple codes will really help me a lot, as i m new in this filed.
Thanks in advance.
Regards,
ADARSH
|
|
|
|
|
I am trying to code a generic function under the Click event of an Edit > Copy menu. It needs to get the text value of the current textbox (or whatever) and place that value on the clipboard. I tried the following:
Clipboard.SetDataObject(Me.ActiveControl.Text)
However, the window form in question actually contains a grid and a second windows form container which has the actual text boxes on it. As a result, "ActiveControl" is in fact the containing control.
As a convert from a 4GL to VB.NET, I am struggling with the basic issues like getting the currently focused control. Most of the examples are so basic as to be useless in a real application. Any suggestions would be greatly appreciated.
Regards
David
|
|
|
|
|
Hi David
Try this:
Dim a module level string
e.g. Dim CurrentCtrl as string
In the GotFocus event of each control that you need to get the text, put the following code:
CurrentCtrl = Form1.ActiveControl.Text (replace Form1 with actual form/location name)
Then from your menu you can send the value in CurrentCtrl to the clipboard.
Below is some code to give you the idea, if you need it.
On the form is a frame; inside the frame are 5 text boxes. There's a menu with two options: To Clipboard and From Clipboard. Also on the form is a label: just displays what's on the clipboard when From Clipboard is selected from menu.
**********************************
Option Explicit
Dim CurrentCtrl As String
Dim LastCtrl As String
Private Sub Form_Activate()
Text1.SetFocus
End Sub
Private Sub mnuFromClipboard_Click()
Label1.Caption = Clipboard.GetText
End Sub
Private Sub mnuToClipboard_Click()
Clipboard.SetText (CurrentCtrl)
End Sub
Private Sub Text1_GotFocus()
CurrentCtrl = Form1.ActiveControl.Text
End Sub
Private Sub Text2_GotFocus()
CurrentCtrl = Form1.ActiveControl.Text
End Sub
Private Sub Text3_GotFocus()
CurrentCtrl = Form1.ActiveControl.Text
End Sub
Private Sub Text4_GotFocus()
CurrentCtrl = Form1.ActiveControl.Text
End Sub
Private Sub Text5_GotFocus()
CurrentCtrl = Form1.ActiveControl.Text
End Sub
*******************************************
Oh, by the way the module variable LastCtrl can be utilised by much the same code as in the GotFocus except it goes in the LostFocus event of each control
Anyhow this should give you a start in the right direction, I hope.
Budgieboy
|
|
|
|
|
Thanks for that. However if you have a lot of fields, this will result in a huge overhead in code. Or alternatively, I could place this in a class and inherit, but that still has issues. From this and other forums where I posted the question, it seems like VB.NET doesn't have what I was looking for. However another source provided a lead which resulted in the code below:
Private Function ClipboardCopy()<br />
<br />
Clipboard.SetDataObject(GetActiveControl(Me).Text)<br />
<br />
End Function<br />
<br />
Private Function GetActiveControl(ByVal container As IContainerControl) As Control<br />
Dim control As control<br />
<br />
control = container.ActiveControl<br />
If TypeOf control Is IContainerControl Then<br />
Return GetActiveControl(CType(control, IContainerControl))<br />
End If<br />
Return control<br />
<br />
End Function
This gives the result I was looking for.
Regards
David
|
|
|
|
|
Hi,
I'm making an application in VB and I need to have an option to open it on the Windows Explorer popup menu(show's when you right click a file) with all files but one(the file type my program actually reads) sort like winzip does. and for one special file type(the file type my program actually reads). I also need some special options on it's popup menu.
If anybody knows then please reply asap.
Thanks and Regards
Mayank Kumar
|
|
|
|