|
You can save the value of mainForm in your class as a class variable.
If the mainForm is the first form that is created and the last form that closes then it will not change.
|
|
|
|
|
That is nice and all, but completely bad practice in an Object Oriented language.
You're other class is now forever tied to this form and only this form. You'll never be able to reuse it in any other project, or even any other form, unless it's built speicifically with this class in mind.
Any code that changes the form should remain in the form's code, not in a seperate class. The form's code is responsible for updating the UI it's showing. If your class has to return a value that changes the form, the form code should be evaluating that return value and making any necessary changes. Keep the UI code in the UI layer, not the business layer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave. You are right. I have very little experience with Visual Basic so it was a struggle to get ANYTHING to work. However since I'm at the start it should be fairly easy to change it to return things to the form and have the form make the changes.
Ilan
|
|
|
|
|
IlanTal wrote: I think you got slightly confused as to who changes who.
I want the function to change the form.
No, I'm not confused about that.
IlanTal wrote: It doesn't recognize 'this', but on the other hand it knows what 'Me' is. Likewise it doesn't know what 'Form1 mainForm' is but it does know what 'ByRef mainForm As Form1' is.
Right. I'm only programming C# myself, so I mixed up the syntax a bit. Sorry for that.
There is no reason to specify ByRef for the reference, though. You are not going to replace the main form with a completeley new form in the method, are you?
IlanTal wrote: Do you know if I could save the value of mainForm in my class in case I need it outside of the Init function? I could make it a class variable, but the question is if it could change? My gut feeling is that it wouldn't change since it is the main form.
Yes, you could. The reference to the main form won't change as long as the form is open.
However, as I suggested before, I reccommend that you just send a reference to the control that the method is going to change. That way it's obvious what the method is going to update, and as the method isn't locked to a specific control you might be able to use the method for more than one control.
---
b { font-weight: normal; }
|
|
|
|
|
i use data grid to show my main information from ADODC,
but i wanna add a function on when user click on the selected line on data grid, the sub information will show at the other list view or data grid...
is it better to show in data grid or list view for the sub catagory?
Exmaple,
MY recent Datagrid show the receipt No. when user click on it, the list of item will show out for that specific Receipt no.
|
|
|
|
|
campbells wrote: is it better to show in data grid or list view for the sub catagory?
it all depends on the requirement.. Datagrid is good option if you are going to edit that information or even for Viewing only. ListView is good for viewing only not for editing.
|
|
|
|
|
do u know how to command on when specific record was click then it will show the sub category ??
i have show my information in the data grid ,now i want to show it sub information when the data grid record was selected..
|
|
|
|
|
How do I create a custom control with a datasource that populates its dropdown with the list of available datasources? There is no dropdown.
|
|
|
|
|
This seems to be the answer:
<category("data"), _
="" attributeprovider(gettype(ilistsource)),="" _=""
="" refreshproperties(refreshproperties.all),="" browsable(true)=""> _
Public Property DataSource() As Object
...
End Property
I earlier had it coded AttributeProvider("IListSource")
|
|
|
|
|
I'm a newbie so I'm sorry if this is a stupid question.
Could someone give me the highlights of what vb.net functions I would use to get XML from a webservice into a dataset on a vb.net windows form ?
I have a skeleton webservice and I can see how I can add a sqldataadapter to it. But I cant figure out how to make the webservice publish the data from the sqldataadapter as XML. Or how I would take that XML and put it into a dataset on the client.
Thanks
|
|
|
|
|
If you are trying to have the webservice provide a typed-dataset to the client you will need to write a function on the webservice to return one. You will need to first create a dataset in the webservice project (right-click the project name, select 'Add new item', select 'Dataset', and configure it to your liking). You can then write a function to return that dataset; for example:
<Webmethod()> _
Public Function GetTypedDataset() as myDataset
Dim TableAdapter1 as myDatasetTableAdapters.TableAdapter1
Dim TableAdapter2 as myDatasetTableAdapters.TableAdapter2
Dim returnDataset as new myDataset
TableAdapter1.Fill(returnDataset.Table1)
TableAdapter2.Fill(returnDataset.Table2)
Return returnDataset
In your client project, you can select 'Add a new datasource', select 'Web Service', and follow the Wizard to select your web service.
The typed-dataset will then be useable in your client application. To fill it, you would call the function demonstrated above. You would also need to write methods on the webservice to handle updating, and call them from your client as needed.
Hope this helps,
Keith
-- modified at 0:06 Wednesday 9th August, 2006
|
|
|
|
|
Thats a great help - thanks
|
|
|
|
|
I'm using Visual Studio 2003 - are tableadapters available in 2003 ? Or should I use an alternative approach ?
Thanks
|
|
|
|
|
Suppose i have two buttons btn1 and btn2 and i have created a click event function of btn1. now if i want to call btn1 click event function when user click btn2 please tell me soon
|
|
|
|
|
|
Another method is to have the same event handler handle the Click event of both buttons. Look at the end of the event handler declaration for one of the buttons Click events and you'll find a Handles clause:
Private Sub Button1_Click(blah, blah) Handles Button1.Click
You can have a single handler handle the Click events of more than one button by doing this:
Private Sub MyClickHandler(blah, blah) Handles Button1.Click, Button2.Click
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Button1_Click(nothing,nothing)
U Xux
|
|
|
|
|
I am writing a VBA macro in Excel, and have declared 2 global string arrays.
I am manipulating these arrays in a couple of function without passing them as params -since they are global- however when I return from the first function my array is losing its elements. Is this code error, or am I missing something with arrays.
|
|
|
|
|
Ok the problem is because when I was debugging I added a watch for the array variables via the array var in the procedure, which would give it a out of context value when out of the proc. So lesson is when using globals to add watches on the global declaration not the var within a proc to ensure you have the value of the global representation.
|
|
|
|
|
Hi,
How to put checkbox in datagrid through DataGridColoumnStyle.
Plz help me.
|
|
|
|
|
You need to add a DataGridBoolColumn to your grid's column collection.
Steve
|
|
|
|
|
When DataGridBoolColumn is used the checkboxes are displayed as disabled,
does not allow editing.
|
|
|
|
|
Is your column bound to a table column?
These checkboxes have three states, checked(True), unchecked(False) and DBNull.Value
What is the code you have used to set up the column?
Steve
|
|
|
|
|
Hi,
I'm creating an app that polls a folder (source folder) for files and moves them to another folder (destination folder). I've identified two main reasons that the move may cause an exception to be thrown.
1. The file is still being copied into the source folder by another process. Therefore the file is locked, and I need to try again later.
2. The file already exists in the destination folder.
In my catch block I need to differentiate between the two errors and handle them differently. I realise that I should perhaps be checking that the destination file does not exist before doing the move which would stop 2. happening, but it raised an interesting question for me.
What is the "proper" way do distinguish between the two errors? Obviously the IOException.message is different, but is that the way to do it?
Thanks
Ant
|
|
|
|
|
The documentation doesn't say what exception you get if the file is locked. Do you get an IOException for that too?
---
b { font-weight: normal; }
|
|
|
|