|
Please tell me how to add form into tab control.
Thanks.
|
|
|
|
|
You cannot. You can define your form as a user control and host that control in a form, to make a form of it, or in your tab control.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I have a class that refreshes a datagridview control. I can call this from various places including forms and it works. It is located in a module.
I have a 2nd module with a class that calls the refresh class from the 1st module and for some reason i can do nothing with the data grid view. Msgbox tells me it is going into the refresh class but i cant even set the datagridview.row count to 0.
Example:
module functions
--Public Class DGV
----Public Shared Sub refresh()
Dim dataGV As DataGridView
dataGV = My.Forms.mainWindow.DataGridView1
dataGV.RowCount = 0
----end sub
--end class
end module
module runtime
--Public Class Watcher
----Public Shared Sub Run()
Call DGV.refresh()
----end sub
--end class
end module
Seems so simple but its killing me - from any form (button_click or form_load) it works fine over and over again. I reference it in a 2nd module and the datagrid does nothing... not clearing...
|
|
|
|
|
commieJerk wrote: ----Public Shared Sub refresh()
Dim dataGV As DataGridView
dataGV = My.Forms.mainWindow.DataGridView1
dataGV.RowCount = 0
----end sub
This is really nasty. Your code is strongly tied to a specific form, why would you call a dll, just to look for a form, and grab a UI element ( which really shouldn't be public anyhow ), and set a property on it ?
If you have a genuine need to do this in a function, pass the datagridrow into the function.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ok yea I changed it to Public Shared Sub refresh(ByRef dataGrid As DataGridView).
I am just starting VB - coming from a VBA (access) background so im not used to a lot of basic programming stuff yet cause access does a lot of this stuff for you.
What i am trying to do in a nut shell is - using FileSystemWatcher(), update a datagridview when its change event fires. The problem is doing anything inside the event. I can put stops inside the refresh class and it seems to be clearing the datagridview and reloading the data but it dosent.
When I call the refresh class anywhere elese it works fine?
|
|
|
|
|
OK, this is the FileSystemWatcher that's firing an event ? I don't see any reason why code that's run in there would behave any differently. Is that code in a different dll to the main app ? b/c the main problem I'd expect is that you're updating the wrong datagridview - how do you access it ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
' Add event handlers.
<code>AddHandler watcher.Changed, AddressOf OnChanged</code>
' Define the event handlers.
<code>Public Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)</code>
'OnChange gets fired twice for each update so make sure we only do stuff once.
<code>If bolChanged = False Then
Call DGV.refresh(My.Forms.mainWindow.DataGridView1)</code>
'this wont even run -> My.Forms.mainWindow.DataGridView1.rowcount=0
<code>bolChanged = True
ElseIf bolChanged = True Then
bolChanged = False
End If
End Sub</code>
|
|
|
|
|
Oh yea and even trying to set the text on a textbox wont work - but msgbox and the console work fine. Is this a limitation of the event sub?
|
|
|
|
|
Ok i found what i was doing wrong. I didnt realize the FileSystemWatcher event was on the .IO thread and to update a UI I had to use SynchronizingObject = My.Forms.mainWindow to update it. It works great now
|
|
|
|
|
my problem is i am about to enter new dates:
for example the new date is 6/6/2007 8:15:16
then i need to check if this new date will fall between an existing date...
existing date : 5/6/2007 8:23:54 and 7/6/2007 9:45:10
how could i be able to do that... can you give me a solution... i dont know if there is a predefined function for that...
thnx!
|
|
|
|
|
The < operator works with DateTime. So create your two range datetimes, and then check if your date > one and < the other. I'd write a helper function to do this.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
I am trying to add a combo box to a datagridview, using the code below. However, i get the following error message: "Object reference not set to an instance of an object."
I also get this repeated message every few seconds. "The following exception occurred in the datagridview:
system.argumentException: Datagridviewcomboboxcell value is not valid.
To replace this default dialog please handle the dataerror event"
I haven't added the combo to the datagridview at design time, only in the code below.
Try<br />
'Fill the datagrid<br />
Me.TA_OrderSoftwarePart_dsCodeRed1.Fill(Me.DsAddComponetAndEquipment.OrderSoftwarePart)<br />
Me.dgvOrderSoftwarePart.DataSource = Me.bsOrderSoftwarePart<br />
<br />
Dim dgvc As DataGridViewComboBoxColumn<br />
dgvc = Me.dgvOrderSoftwarePart.Columns("Status")<br />
<br />
dgvc.Items.Add("To be Ordered")<br />
dgvc.Items.Add("Ordered")<br />
dgvc.Items.Add("Delivered")<br />
<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try
Many thanks for any help with the code above,
Steve
|
|
|
|
|
I only had time for a quick look, but you created a reference to a POSSIBLE DataGridViewComboBoxColumn. You didn't actually create a new column. Change this line:
Dim dgvc As New DataGridViewComboBoxColumn
|
|
|
|
|
Hello,
I didn't use the new key word, as I don't want to create a new column but convert an existing column into a combo box column.
In my database table I have a column called status. This can be either "To be Ordered", "Ordered", or "Delivered".
So when datagridview displays in the form, it will allow the user to select either one of them.
Many thanks,
Steve
-- modified at 1:52 Wednesday 27th June, 2007
|
|
|
|
|
Well, that's where the "Object reference not set to an instance of an object" came from.
If I get your meaning, you can't change the type of the column once it's created. For example, you can't change a TextBoxColumn into a ComboBoxColumn. You can, however, hide the original TextBoxColumn, create an entirely new ComboBoxColumn, add it to the columns collection and setup it's properties to bind to the appropriate column in the dataset.
|
|
|
|
|
I've been trying to do the same thing. Could you post code for adding the ComboBoxColumn and binding it to the appropriate column in the dataset?
Thanks,
Diane Volk
|
|
|
|
|
Quick and dirty:
Dim col As New DataGridViewTextBoxColumn()
With col
.DataPropertyName = "Description"
.HeaderText = "Description"
End With
DataGridView1.Add(col)
|
|
|
|
|
This worked perfectly. I was missing setting the DataPropertyName in my code.
Thanks!
Diane Volk
|
|
|
|
|
Hello, I'm using Visual Basic 2005. I created html pages inside the webbrowser1 object. I added a text box and search button above the container. I would like the user to put in a word and click the search button to search for that word on the html pages, which are located in the webbrowser1 object container. Can this be done? Does anyone know how? Please help.
|
|
|
|
|
Of course it's possible.
One question - What do you mean by "webbrowser1 object container"? HTML files are just text files stored on the hard drive.
|
|
|
|
|
I typed all my help documentation inside of this webbrowser1. I placed the webbrowser1 container on my form from the toolbox and then typed documentation and placed jpegs pics inside. I placed a textbox and a button at the top of this form (they are not part of the container) and I want to be able to type a word in the textbox, that's in the HTML document and hit the button to take me right to where this word is in the document. How do I search the html document?
|
|
|
|
|
this is the code i have thus far. It works..I just want it to highlight in the document.
Dim selStart As Integer
Dim seekString As String = tbSearch.Text.ToString
Dim textStart As Integer
textStart = tbSearch.Text.IndexOf(seekString)
If textStart > 0 Then
tbSearch.SelectionStart = selStart - 1
tbSearch.SelectionLength = seekString.Length
End If
tbSearch.ScrollToCaret()
|
|
|
|
|
Pardon me, but if you look in the toolbox of visual studio 2005 towards the bottom under COMMON CONTROLS and ALL WINDOWS FORMS, there's a object called webbrowser. It enables users to browse web pages inside your form. Take a look! This is a windows application.
|
|
|
|
|
I know precisely what the WebBrowser control is and how it works. What you said you did just isn't possible using THAT control. You cannot type in it at all!
|
|
|
|