|
The small app that I am developing is a simple form with a tab control on it. The form currently performs the following:
On load it dynamically creates a TabPage and dynamically creates a RichTextBox inside that new TabPage.
Their is a menu option and a context choivce that will create a new TabPage with a new RichTextBox inside the same TabControl.
Here is the problem:
When I use the SaveDialog I can save the first Tab that was created but I cannot seem to save the other tabs that I dynamically create.
I think that the reason is that I use the same object names each time and I don't know how to differentiate between them. I have tried doing SelectedTab but then I don't know how to address a RichtextBox that is not there before runtime.
Any ideas?
Thanks,
Taen Karth
|
|
|
|
|
Try the following:
For Each tabCtl As TabPage In TabControl1.TabPages
For Each ctl As Control In tabCtl.Controls
If TypeOf ctl Is RichTextBox Then
' Code to save the contents....
End If
Next
Next
Hope this helps.
|
|
|
|
|
That sounds perfect. I have no clue why I did not think of that. I did all variations except that...lol. I will try when I get home and let you know.
Thanks!!
Taen Karth
|
|
|
|
|
Excellent work. I was not able to use all of it as I did not want to save the text in a textboxes in all tabs rather only the selected tab. I was able to it as follows to save the text in only the selected tab.
'Declare private variables<br />
Dim strName As String = "NewNote"<br />
Dim sw As StreamWriter<br />
Dim FileName As String<br />
<br />
'Start Save As event<br />
Try<br />
For Each ctl As Control In TabControl1.SelectedTab.Controls 'Find all controls on the selected tab page<br />
If TypeOf ctl Is RichTextBox Then 'Get the Rich Text Box<br />
'Start the SaveFile Dialog event<br />
With sfdSaveAs<br />
.FileName = strName<br />
If .ShowDialog = Windows.Forms.DialogResult.OK Then 'If user clicks save then...<br />
FileName = .FileName<br />
sw = New StreamWriter(FileName) 'New stream Writer<br />
sw.NewLine = ControlChars.NewLine 'Set StreamWriter's New line to the newline character<br />
sw.Write(ctl.Text) 'Write CTL which is RichTextBox in selected tab<br />
End If<br />
End With<br />
End If<br />
Next<br />
Catch es As Exception 'If there is an error<br />
MessageBox.Show("An error has been encountered. Please try again.")<br />
Finally<br />
If Not (sw Is Nothing) Then 'If there is nothing to write then close the streamwriter<br />
sw.Close()<br />
End If<br />
End Try
Thanks again,
Taen Karth
|
|
|
|
|
Looks good. I'm just glad to have been of some guidance.
What exactly are you building, if you don't mind my asking? I sounds like a Notepad substitute, if it is, I like the tabbed approach.
|
|
|
|
|
That is exactly what I am building. I work in a firm where I have to take lots of phnoe calls and remember lots of little side notes. I am using this to build a Notepad Substitute. Each new tab will have a time and date stamp on the top of the tab so that I know when I jotted in it. I will also be able to save each tab individually and set the opacity so that I can compare with stuff behind it without having to switch back and forth. I am using VS.NET 2005 Beta to develope it so You have to download the new .NET Framework 2.0.?? beta as well to run the apps. If you are interested I will send you the source so you can peruse it. I will put it up on some free site when I am done as well if you would rather wait.
Thanks again for the tips,
Taen Karth
|
|
|
|
|
Yes I'd love to see what you have so far, and maybe I can be of some assistance. I'm always looking for new challenges. Also, I have been looking for an excuse to use VS.Net 2005, but I have been a bit lazy and out of ideas. (Too many brain cells used at my real job. lol)
|
|
|
|
|
I noticed a bug with using ShowDialog to display a custom dialog box, and then using ShowDialog from that custom dialog to display a FolderBrowserDialog.
The problem is when I select "Ok" or "Cancel" on the FolderBrowserDialog, both dialog boxes disapear.
Has anyone else run into this problem?
And if you have, have you been able to get around it?
Thanks in advance.
|
|
|
|
|
I want to do a while TName "does not equal"
A.K.A " != "
While TName != "Rangers"
but it's not letting me do it, so I assume that my syntax is wrong. Not used to VB.net. Keeps giving me a "End of statement expected".
|
|
|
|
|
Do While TName <> "Rangers"
Loop
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
|
I need some guidance regarding a Windows Service Application and MS-Outlook 2000 type library (msoutl9.olb)
My service app needs to scan an outlook inbox at regular intervals and process incoming email messages. My problem is that the application is unable to create the instance of the Outlook.ApplicationClass() object.
The app has the proper installers and has been installed to run on the local machind under the LocalSystem account.
The Outlook application and namespaces are declared at the beginning of the class definition:
Protected Friend olApp As Outlook.ApplicationClass<br />
Protected Friend olNS As Outlook.NameSpace
I attempt to start the Outlook instance in my service's OnStart() event:
Protected Overrides Sub OnStart(ByVal args() As String)<br />
<br />
'write entry that service has started<br />
EventLog1.WriteEntry("KeyMailSvc Started")<br />
<br />
Try<br />
<br />
'start outlook app and open namespace<br />
olApp = New Outlook.ApplicationClass()<br />
olNS = olApp.GetNamespace("MAPI")<br />
olNS.Logon("", "", False, True)<br />
<br />
'start the timer<br />
With Me.Timer1<br />
.Interval = 30000<br />
.Enabled = True<br />
End With<br />
<br />
<br />
Catch ex As System.Exception... (some error logging goes here)<br />
<br />
I do not get to the Catch. Attempts to start the service time out and I get a MS error message "The server {0006F03A-0000-0000-C000-000000000046} did not register with DCOM within the required timeout." in my System log.
If I compile the same code as a WinForms app and move the Outlook code to the Form_Load event, I have no problems. Can anyone shed some light on this for me?
|
|
|
|
|
Just a quick note...
When I change the object type from Outlook.ApplicationClass object to Excel.ApplicationClass object, the service starts.
Protected Overrides Sub OnStart(ByVal args() As String)<br />
<br />
'write entry that service has started<br />
EventLog1.WriteEntry("KeyMailSvc Started")<br />
<br />
Try<br />
<br />
'start outlook app and open namespace<br />
Me.olApp = New Excel.ApplicationClass()<br />
'Me.olNS = olApp.GetNamespace("MAPI")<br />
'Me.olNS.Logon("", "", False, True)<br />
|
|
|
|
|
I have a VB6 application that I am upgrading to VB .NET
I am having difficulty with pupup menus, (right click an item and pop a menu based on current system status) any samples or examples of how this can be done would be appreciated.
|
|
|
|
|
Are you referring to context menus?
If so, simply drag a context menu from the toolbox into your designer window. When highlighted, it will appear as a menu at the top of your form where you can customize it and add menu items.
Assigning it to controls is easy. Simply select a control on your form, and change the Context Menu property to your newly created context object.
Hope this is what you mean?!
|
|
|
|
|
Hrmph... Kinda guess I got thrown off looking for a tricky way to do it. Thanks for your help, just what I was looking for...
|
|
|
|
|
Ok, so I have created my ActiveX control (using VB6) and now have an .OCX file (with others from the compilation).
I know that when I register this .OCX file from inside my target application (MS Access), I can use the control I created.
How can I distribute this when I update my Access "application" on other PCs?
Do I need to do anything, OR is distributing my latest .MDB file (which includes my inclusion of my ActiveX control) good enough? The later I can try.
Reason: I want to eliminate the user's need to go through Tools | ActiveX Controls | Register | (browse for my .OCX file).
Thanks,
Johnny
|
|
|
|
|
I have a couple of different procedures that retrieve data from a single database. Both return a single value, either an Integer or DateTime. But the one that returns an integer accesses the data by connecting to the database and returning the data using .ExecuteScalar, while the other one builds a DataAdapter, a DataSet, and a DataTable, then references the DataTable to get the data.
my question is, is there any advantge to using DataSets over directly query-ing the database?
|
|
|
|
|
The difference here is not the dataset or not, it is the data adapter or the execute scalar method. Executescalar returns a single value and will always return a single value. The other query, if it always returns a single value would possibly benefit from using the executescalar method b/c it wont use all that memory overhead with datasets and adapters and such.
If you will need to return more than a single value then you have 2 choices really, the dataadapter allows you grab a dataset or fill a datatable - or you can use a datareader. Both return a set of data and have their benefits and problems.
So after a long windy explaination - you are querying the database no matter what, but one uses more objects to get the data.
Cleako
|
|
|
|
|
I have a DataAdapter that joins 3 tables together. The DataAdapter fills a DataSet from these tables. How can I add a new row to the DataSet? I'm using the code below to do this but it errors out on the last line.
Dim newrow As DataRow
newrow = MyDataSet.Tables("MyDataTable").NewRow()
newrow.Item("column1") = 0
newrow.Item("column2") = 1
newrow.Item("column3") = 1
MyDataSet.Tables("MyDataTable").Rows.Add(newrow)
Thanks again in advance.
|
|
|
|
|
I cant see an obvious problem with this code, its very similar to something I use currently.
What exactly is the error?
|
|
|
|
|
Error message is:
"Object reference not set to an instance of an object."
Is the problem because I have more then one table in the DataAdapter? Adding a record to the DataSet is Ok, but the DataSet maps back to three tables. How does it know which of the three tables should end up with the new row?
|
|
|
|
|
1. How do I dynamically generate a datagrid and trap the keyboard keys or mouse click in a datagrid cell?
2. How do I prevent from user to add more rows to datagrid?
3. How do I add the footer totals and change them according to the datagrid cell values?
Simpra
|
|
|
|
|
hi guys!
I'm working on a project now, i need to shut down windows XP via vb6 code.
Can somebody please help me about this subject?
|
|
|
|
|
Run the remote windows shutdown application using the "shell" command. The path for the application is:
C:\WINDOWS\system32\shutdown.exe
°[Halo]°
Project Basilisk
|
|
|
|