|
Taken together, your posts don't make any sense:
- your first message said: error "No row can be added to a DataGridView control that does not have columns. Columns must be added first."
- Now you say it is all happening in this line: tbR.Text = RadEntry(1) which is unrelated to any DGV, as RadEntry is a string array.
This does not make any sense. My advice is:
- if you haven't done so yet, tell your IDE to always show line numbers in edit windows (see #101 and 102 here)
- put the entire content of PopulateGrid in a try block, catch a general Exception and display the entire Exception.ToString()
- do a clean build (remove the bin and obj folders, click Clean Solution, click Build)
- make sure there are no compilation warnings/errors. If there are, fix them.
- now run, and observe carefully.
- if it goes wrong, debug. Which means: observe more detailed and even more carefully. Use break-points and single-stepping. Come up with an hypothtesis, and prove it right or wrong. Until you find and solve the problem.
|
|
|
|
|
I really don't know what the heck is going on and what to make of it.
Anyway, linenumbers are on.
Try...Catch block is in place and it catches ex as Exception (thats a general exception right?)
Also, is there a difference between
ex.message and
ex.tostring?
The errors/warnings list is empty, so no errors and warnings.
Removed the bin and obj folders.
Debugging now.
Ok, i ran through it. Now it does'nt give the error at the tbR.Text = RadEntry(1) line but at the dgvRAD.Rows.Add(... line.
Whut? Visual Studio is playing games with me.
But the error is still there. However, when i remove the event link of the radiobutton and add an addhandler line at the end of form_load, it works just fine. Finally.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Hi, dear all,
I add a DataGridView to a form, I want to add row header to it. I call the following function while initialize this gridview to wish to put the row number to the row header, but it didn't shown. Do I need to set some properties to dispaly row header??
Private Sub NumberAllRows(ByVal grdStudents As DataGridView)
' Add row headers.
For i As Integer = 0 To grdStudents.Rows.Count - 1
grdStudents.Rows(i).HeaderCell.Value = i.ToString()
Next i
End Sub
Thanks!
|
|
|
|
|
|
That just works fine.
Just check the width of your rowheader, if it is less then 30, numbers will not be shown.
Make it 50 or so.
I've checked this code which uses same code, and works fine.
http://www.vb-helper.com/howto_net_datagridview_row_headers.html
|
|
|
|
|
I have to use data grid in VB 6.0 How can I make it and how can I add the columns in it.
Thanks in adv..
|
|
|
|
|
It's obvious you're new to VB development. I highly suggest abandoning VB6 and move to VB.NET before you learn too many of VB6's bad habits.
The control you're looking for is the MSFlexGrid. No, I don't have any tutorials on it because I abandonded all VB6 developement almost 10 years ago.
|
|
|
|
|
I am reading an xml file.My code is as follow-
Dim XmlDoc As New DOMDocument30
Dim nodlst As IXMLDOMNodeList
Dim nod As IXMLDOMNode
Dim Data As String
XmlDoc.async = False
'Loading the XML file on C drive
If XmlDoc.Load(TextFilePath.Text) Then
Set nodlst = XmlDoc.selectNodes("/Request")
Set nod = nodlst(0).selectSingleNode("Responce")
Set Data = nod.Text
MsgBox Data
End If
where TextFilePath.Text is the path of the xml file and file structure is as -
<Request>
<Responce>File Not Found</Responce>
</Request>
On compiling my code it is giving an error-
"User-defined type not defined......"
Please how can I rea data from xml file.
Thanks in adv..
|
|
|
|
|
There's a nice example here[^]. Did you remember to include the reference to the Xml-library?
I are Troll
|
|
|
|
|
I've been tasked with figuring out why our slides in PowerPoint are flickering when the text of an onscreen shape is changed through the code. We have a timer that counts down from 30 and occasionally while it's counting all of the objects that have any animation attached to them will flicker -- looks like they're being redrawn. But it's not every time the text in the timer is updated. I have not been able to discern a pattern. Apparently this started happening in PowerPoint 2007 and did not happen in PowerPoint 2003.
Anyone come across something like this?
Thanks!
Denise "Hypermommy" Duggan
|
|
|
|
|
I’m using Excel VBA. I have a menu structure that appears when the spreadsheet loads. This code is in Module1 which is called from ThisWorkbook with the command “Call Sub AddMenus()”. The code samples below show the structure I’m working with. From UserForm1, for example, I need to reference a variable. I assume I need to create an object to talk to Module1 but can’t figure out how to do that in VBA (I’m familiar to C# but new to VBA).
Module1
Public Sub AddMenus()
Dim FormIndex As Integer
Dim ReportViewName(2 To 4) As String
‘create menu structure for the workbook
‘read variable values – FormIndex=2, etc.
End Sub
UserForm1
Want to say: “variable = Module1.FormIndex” but obviously doesn’t work
ThisWorkbook
Private Sub Workbook_Open()
Call Module1.AddMenus
End Sub
|
|
|
|
|
Try making "Module1" public - I'm not sure whether it works, but might be that it's private by default. Creating a new variable would only have to be done if it we're a class. I believe a module is a static class in C#-terms, and making it public should make it's methods visible
I are Troll
|
|
|
|
|
Thanks for your quick reply, Eddy. Dumb q: How do I make Module1 public? Also, would it help to put the code in a Class Module?
|
|
|
|
|
Hoping, just the same as you would with a method;
Public Module1
Public Sub AddMenus()
Dim FormIndex As Integer
Dim ReportViewName(2 To 4) As String
‘create menu structure for the workbook
‘read variable values – FormIndex=2, etc.
End Sub
Tim Bostwick wrote: Also, would it help to put the code in a Class Module?
That would make it a class, and you'd have to create an instance before you use it;
Dim MyVar as ClassModule1
Set MyVar = New ClassModule1
What version of Excel are you in BTW?
I are Troll
|
|
|
|
|
Wouldn't something like below allow you to access the value of the variable outside the function?
Public Module1
Public FormIndex As Integer
Public Sub AddMenus()
Dim ReportViewName(2 To 4) As String
‘create menu structure for the workbook
‘read variable values – FormIndex=2, etc.
End Sub
If so, do look into class modules and create a property with a getter
I are Troll
|
|
|
|
|
Right, but when AddMenus() runs, it won't create the FormIndex variable, right?
The general issue is, How do you use Workbook_Open (in ThisWorkbook) to load public variables in Module1?
Possibility #1: Do as you indicate above, make FormIndex public with the problem already mentioned.
Possibility #2: Declare FormIndex public in ThisWorkbook. But I also have arrays that need to be read and ThisWorkbook won't allow arrays?
Is there any way to get all of Module1 read by Workbook_Open?
|
|
|
|
|
Hi
Have you actually tried the Possibility #1 you mention above? In the AddMenus in Module1, try assigning a value to the FormIndex variable and then get the value to display in your UserForm... I think you will find that it works!
|
|
|
|
|
Chandra: Yes I did but the problem is that FormIndex is outside the AddMenus sub so it won't be read into memory when I call AddMenus. I solved the problem, however, by realizing that I don't have to load all the arrays at once. I'm used to that approach from programming in C# where I just read everything up front as public and then have them available throughout other programming. I started thinking more of a per-Sheet approach for VBA and things work fine by putting the read-the-array code with each UserForm. So now I don't need to invoke from ThisWorkook.
Old code, quoting from a previous post:
Public Module1 ' static class
Public FormIndex As Integer ' outside the function, compareable to a static variable
Public Sub AddMenus() ' static method
Dim ReportViewName(2 To 4) As String
‘create menu structure for the workbook
‘read variable values – FormIndex=2, etc.
End Sub
|
|
|
|
|
Variables declared within procedures ("sub") are not available to be referenced outside the procedure.
To make it available, declare it as
Public FormIndex as Integer
before the code for any procedure.
For instance, your Module1 code should look like this:
Option Explicit
Public FormIndex as Integer
Public Sub AddMenus()
Dim ReportViewName(2 To 4) As String
‘create menu structure for the workbook
‘read variable values – FormIndex=2, etc.
End Sub
You will now be able to reference this variable from within your UserForm.
|
|
|
|
|
Hi Chandra: Thanks for your reply. I understand how to make variables public, ouside the sub. What I'm trying to do is declare certain variables public as part of Workbook_Open which calls the sub AddMenus(). But the only way to make the variables public is to declare them above AddMenus()in Module1 but that means they won't be read when Workbook_Open calls AddMenus()!
|
|
|
|
|
Hi
That is not entirely correct... all variables declared as public within modules are available to the entire VBA project, even at the WorkBook_Open sub. So, if you declare your variable as per my example, you will see that you can reference it within the WorkBook_Open sub too
|
|
|
|
|
Let me try to explain it differently. Here's the structure:
In ThisWorkbook:
Workbook_Open()
Call Module1.AddMenus
In Module1:
Public Var1
Sub AddMenus()
private variables
End Sub
In UserForm1:
do something with Var1
When ThisWorkbook loads and reads Workbook_Open, it calls AddMenus but it *doesn't* read Var1 into memory. So UserForm1 can't access it. if Var1 is put inside AddMenus, it'll get read but it won't be public. And... if I put Var1 into ThisWorkbook as public, that's won't work if Var1 is an array.
|
|
|
|
|
Hello mates.
Need help.
I have datagridview which has paging like in gridview of asp.net and
its smoothly working. The problem when I add a new row
in the second page it goes to first page.
Goal:
User will able to add new row by clicking add new row button. Then if
the row is more than 12rows, the next/previous button will enabled
and if the user still click add new row button. the 13th row or more
will go to second page. Then if the user will go to second page then
add row, it should not go to fist page.
Thanks in advance.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
I have a database search function on a Windows form app that needs to be readily accessible, but I don't want it displayed on the form at all times as it is confusing since you can search the same fields that you can edit on screen.
Long story short is I would like the search menu to behave like the toolbox / server explorer / data source left docked tool strip in VS 2008. Right now I have created a tool strip and docked it left and have the buttons the way I want them, but I do not have an eloquent solution for the pop out and pop in functionality.
I put a panel into place that has the search functionality and I simply made it visible = false until the search button is pressed.
If pnlSrch.Visible = False Then
pnlSrch.Visible = True
gbPhoto.Visible = False
Else
pnlSrch.Visible = False
gbPhoto.Visible = True
End If
Is there a more eloquent method of creating a slide in slide out side menu without using WPF?
|
|
|
|
|