|
Is there a way to 'walk' the Document Outline tree and iterate through each control/object displayed? I am working on an in-house project for applying default settings to various controls on a form.
I've tried doing a recursive loop through Me.Controls, identifying if the control as children, and so forth. The problem is that we are using a mixture of standard VB control as well as third-party control (DevExpress, ComponentOne, etc) and the third-party controls are not always a part of the Me.Controls collection. However, they do appear when viewing the Document Outline tree for a given form. So I got the idea to see if I could walk the Document Outline, identify the various controls, and apply settings that way. Of course, I've found no way to walk the Document Outline.
If there's a better way to do this, I'm open to suggestion. Otherwise, I'd appreciate any help or direction that someone could offer. Thanks!
|
|
|
|
|
If you're talking about an ASP.NET webform, move this question to the ASP.NET forum.
If you're talking about a Windows Forms form, there's no such Document Outline concept and you'll have to further explain what you're talking about.
|
|
|
|
|
I'm talking about a Windows Forms project in Visual Basic 2005.
To see the Document Outline panel, open a form in your project, and click on View ->Other Windows -> Document Outline. The keyboard shortcut is Ctrl+Alt+T.
What I want to do is iterate through the objects represented in the Document Outline. Because some objects aren't available through the Me.Controls collection, I need another method to iterate through them. The Document Outline shows all objects, even those that are not available in the Me.Controls collections. I am hoping there is a way to iterate through that tree structure to reference the objects.
Thanks again in advance for any assistance.
|
|
|
|
|
OK. The Document Outline you're talking about is the Controls collection of the Form being designed, and every Controls collection of every control in it.
There is no seperate DOM for Windows Forms other than the Controls collection.
|
|
|
|
|
Can we use the text of a textbox as a query filter in VB? If yes how?
|
|
|
|
|
Yes you want to have a look at the dataview class.
assuming you have data loaded into a datatable, this example i use from the changing of the date in a datetimepicker
dim dv as dataview
dv = new dataview(dt)
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
' MessageBox.Show(DateTimePicker1.Text)
dv.RowFilter = "duedate = '" & DateTimePicker1.Text & "'"
End Sub
Thanks for taking the time, now go away and grow up and return in a newer, more polite and less shouty and ignorant form. - Dalek Dave
|
|
|
|
|
I wanted to ask this way.
I have a query for my data grid view as:
SELECT ID, Name, City, Fee, Technology
FROM [uni list]
WHERE (Name = 'Data')
where data is used as a string and this works fine BUT..
When i refer the filter case to a textbox it doesn't work. It takes this whole thing as a string and not producing the desired results.
SELECT ID, Name, City, Fee, Technology
FROM [uni list]
WHERE (Name = '[text].textbox1')
How can this be resolves
|
|
|
|
|
how do you get your data to the grid? is it via a dataset or datatable?
if datatable then
this bit goes in the event that loads your grid
dim myDataView as new dataview(myDataTable)
Datagridview1.datasource = myDataview
if Dataset then
dim myDataview as new dataview(myDataset.tables(0))
Datagridview1.datasource = myDataview
but the filtering is the same how ever
this bit goes in what you use to fire the filtering, i prefer to use a button to allow filetering
myDataView.Filter = "[Name] = '" & yourTextBox.text & "'"
if you need more help i would need to see your vb.net code as that is where its done and not at the sql statement.
Simon
|
|
|
|
|
Hi Guys!
I am in a bit of a Dilemma here again. As much as office 2007 has provided more options in Excel, it has made it darn difficult to do things which were so easy until Office 2003.
The problem is, I want to create macros which change the background color of the selected cells according to the company colors. There are 6 different colors which need to be applied. I did the record macro option which works fine and places icons next to the save button on the top left corner in Excel 2007. But my boss wants something different, he want a seperate ribbon with the different color options and also that it should be an add-in otherwise it would be hard to implement all these macros on more than 600 computers world-wide. Can anyone please help me out with this one. I have no experience with VB.Net or Microsoft Office programming. I am a web developer but this is something that has been haunting me for a few days now.
To wrap it up, I need to make an Add-In for Microsoft Office 2007 which sits in its own ribbon and has 6 different options. All these options change the background colors respectively, of the selected cells in Excel and needs to be easy to implement by the staff world-wide, we can just provide them with the add-on to run on their computers. Also, this would need to cater for the existing files as well which takes the template files out of the question unless there is a way to make the template file as the default sheet that opens up the existing data.
Any help, suggestions, examples or references will be highly appreciated.
Thanks.
|
|
|
|
|
Sounds like your boss needs to be put in charge of paper clips or something mildly clerical.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Or tied to a home made rocket and shot to the space... lol
|
|
|
|
|
|
Hey mate!
Thanks for that. An amazing article and very user friendly. But now I am stuck on the part where I need to call the function to make the color change. I tried to copy the code from the macro but that keeps giving me weird errors like MissingMemberException: Public member 'Selection' on Type 'RibbonButton' not found etc
Any reference on this would be great. I am googling myself as well but would like to thank in advance.
regards.
|
|
|
|
|
You're welcome.
Unfortunately I have not had to do any projects like this myself, so I haven't tried the code or anything.
Your best bet might be to send the author of the article a message.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi there, I'm newbie here,
I want to know, to set default value for property, which is the best way?
1.
Private _AddFoto As Boolean = False
Public Property AddFoto() As Boolean
Get
Return _AddFoto
End Get
Set(ByVal value As Boolean)
_AddFoto = value
End Set
End Property
Or
2.
Private _AddFoto As Boolean
<ComponentModel.DefaultValue(False)> _
Public Property AddFoto() As Boolean
Get
Return _AddFoto
End Get
Set(ByVal value As Boolean)
_AddFoto = value
End Set
End Property
Thanks
|
|
|
|
|
I always use the method of your first example.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I always use the first case. Does case 2 work? I tried your sample by setting
<Componentmodel.Defaultvalue(True)>... but this doesn't seem to work.
Tosch
|
|
|
|
|
I used the second code, but i didn't realize until your reply.
Yes, the 2nd code doesnt work if we change the value to 'true'
I googling to msdn and find this statement:
"A DefaultValueAttribute will not cause a member to be automatically initialized with the attribute's value. You must set the initial value in your code."
Private MyVar as Boolean = False
<DefaultValue(False)> _
Public Property MyProperty() As Boolean
Get
Return MyVar
End Get
Set
MyVar = Value
End Set
End Property
and it make me more confuse,what is the function of this <DefaultValue(False)>
|
|
|
|
|
Apparently, i missunderstanding what i read before.
componenmodel.defaultvalue is used for other purpose (designer).
thanks
|
|
|
|
|
You have the other responses also, but now there is the new VS2010 way;
Public Property theProperty as boolean = false
Thats it, all the other Get, Set and local private variable are all taken care of under the hood. [which you can still use if you want, or depending on scenario] The local private variable will be named _theProperty by default, and accessible by that name.
|
|
|
|
|
My program consist of a user interface and a separate class that handles the merging of data files. The class is called Merge and when it is done merging the data it raises the event MergeFinished . I declared the following delegates:
Dim WithEvents Merge As clsMerge 'Class that handles the merging of data
Delegate Sub MergeFinishedDelegate() 'MergeFinished Delegate
Private m_MergeFinishedDelegate As MergeFinishedDelegate
Now the sub that handles the MergeFinished event is as follows:
Private Sub MergeFinished() Handles Merge.MergeFinished
If Me.InvokeRequired Then
m_MergeFinishedDelegate = AddressOf Me.MergeFinished
Me.Invoke(m_MergeFinishedDelegate)
Else
Me.Enabled = True
Status.Text = "Merge Finished!"
If Settings.AutoSwitch Then
Dim newFrm As New frmGenerateReports
newFrm.Show()
newFrm.RecieveData(JBNArray)
Me.Close()
End If
End If
End Sub
However the Me.Invoke(m_MergeFinishedDelegate) has an error of "Input string was not in the correct format". This function has been working fine and now it doesn't. I haven't made any changes to this method so I don't know why it broke. Any suggestions?
EDIT: After stepping through the code, this is what I discovered. When the event is first raised, the IF part of the statement is run and the Me.Invoke code works fine. However, when the newFrm.Show() is called then the "Input string was not in the correct format" is thrown within the IDE. Why is the debugger jumping back to the IF part of the statement? And if I keep stepping through, it just loops (calls the invoke, goes the the ELSE statement, and once newFrm.Show() is called the "Input string was not..." is thrown again and the frmGenerateReports is never shown)
modified on Tuesday, April 27, 2010 8:04 PM
|
|
|
|
|
Hi,
I don't think the Me.Invoke line is causing the problem; what it does is cause a thread switch, so your breakpoint/single-stepping debugging techniques probably got confused. I would suggest you put one big try-catch inside sub MergeFinished() , which then shows the Exception.ToString() that is probably occuring. My guess is something actually goes wrong inside RecieveData()
|
|
|
|
|
I have an access table containing several records. Infact records of universities alongwith their fee structure.
The task is to sort out the universities according to a given range and display that list in VB 2008 form.
Has anybody got any reference regarding this?
|
|
|
|
|
This sounds like homework and this little "how-to" has been documented hundreds of thousands of times. All it takes is a little Googling: "vb.net get data from access[^]".
|
|
|
|
|
I have several group boxes on top of one another but the problem i am facing is their merging with each other. How can it be avoided?
|
|
|
|