You can do it like suggested by Dave - the other way could be (perhaps easier to code and to maintain for you) :
- Create the Textbox you want to bring up from the beginning with the Designer.
- Set it's Visible-State to False
- When pressing the Button set it's Visible-State to True.
In this case you are able to make all the relevant connections.
You don't need to modify the Controls-Collection from the Form, catch the Events from the new Control and so on ...
Thank you to everyone for your interest
But it wasn't the answer I would have expected from experienced people like you.
/p.s) But if instead of cloning I asked for a sort of (Textbox) Dynamic with at least 5 possibility of creating (Textbox) on request!
What would have changed?
I'll explain :
If I press the key inserted in the form and I create the first dynamic (Textbox)
How can I go about creating a new one at least five times the same size as the first?
I tried to write something like this; But it is valid only for the first dynamic (Textbox)
Therefore I would miss being able to create all the others every time I press the create button.
They all "default" to the same size and location unless you "change" the property's default value at "construction" time or subsequently. Based on your problem description, that's all that "experience" dictates. If your requirements are more complex, you have failed to articulate them; perhaps it needs "reflection"; but that requires "experience".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
I have created a program that is intended to be used by multiple users (each on their own computer) who access the same SQL database. I have also created a separate updater program to sit alongside the main application. However, I am unsure how to check if there are any users in the main program before the update is run. (This is easy to do on a single user application but not sure on multi-user).
Sorry, but you wrote that every client application is opened on client machine. You don't have to care about other clients.
So, if a single instance of client application is running on client machine, you can close it via updater.
I think what you need to research is the topic of concurrency.
One way to implement this is to have a Modify Date on the primary record.
1) Read the table entry along with the modify date/time.
2) When updating the database, compare the original date/time with the value currently stored, if the date/time has not been changed, then it is OK to perform your update. (Rollback)
During your update you would set the modify date/time to the current date/time. (GetDate() )
I am sure this is not the best format to ask this question/ have this general discussion.
My project is at the barebones, working on a lot of the basics at the moment. The plan is to have a game completely ran on a userform.
Really the only thing I have kind of figured out is the the key logging to track when the space bar, left, right, up, down arrow keys have been pressed. I have only figured out how to do that if a textbox is the focus. Not the happiest with that at moment. Any thoughts on this is appreciated.
I have done a ton of research to see what is currently out there. A majority of the code I find is ran on a spreadsheet, which becomes the base/map. Taking away the spreadsheet leaves my google searches with not many results.
Something I have thought of is having a userform with multiple textboxes like a spreadsheet. Each textbox would be like one cell on a spreadsheet. Problem with this is that I don't think that would do well once trying too get more advance with the game.
The thing that seems like it will be key is keeping track of the pixels location of every object and creating the game logic from there.
The object of the game really isn't the focus right now. To give an end game for my first problem/"curiousosity on how others would go about it" lets say the game is to have a character dodge incoming missles/objects that would come from any direction straight across the board.
I would post my code but it really isn't much at the moment.
1. Please don't respond with something like "why would you do this in vba" or anything like that. I am well aware that there other languages that would better fit this.
2. Sorry for everything being "scatter brained" this is my first time posting a question after about 2 years of doing multiple projects using vba.
3. If there is a better site or resource to use for what I am trying to do please let me know.
There isn't any direct questions, more so looking to get thoughts and opinons on anything I put out there. Appreciate any feedback!
In other VB Windows Forms implementations, the KeyDown/KeyUp events on your Form will only work if the Form has the focus. If the Excel sheet has the focus, they will not work.
Also, in order to get those events to work when any control on the Form has the focus, the KeyPreview property on the Form must also be set to true, though, it appears that this doesn't even exist in Excel VBA.
Basically, without a working KeyPreview property, you cannot do what you appear to want to do.
Good evening everyone.
I'm trying to implement a user control's drag & drop and would like all control to follow mouse movements. However the method does not allow me to move the entire control, but displays the mouse arrow with the classic drag & drop icon.
How can I solve this problem in Vb.net
I have two tables: one as master (Ricetta) the second IngedientiRicetta) as details, in which the details table as a key field that has 'Identity (1,1) ON'.
When I use them on sql 2019 developer server all things run well.
When I use then SQL 2019 Express, I receive the following error:
'When IDENTITY_INSERT is OFF it is not possible to insert an explicit value for the ldentity column in the 'DataTable' IngedientiRicetta,
in System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUp datedEventArgs rowUpdatedEvent, BatchCommandlnfo0 batchCommands, lnt32 commandCount)
in System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdated EventArgs rowUpdatedEvent, BatchCommandlnfo0 batchCommands, lnt32 commandCount)
in System.Data.Common.DbDataAdapter.Update(DataRowO dataRows, DataTableMapping tableMapping)
in System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
in System.Data.Common.DbDataAdapter.Update(DataTable dataTable) in RicetteVB.RicetteDataSetTableAdapters.lngedientiRicettaTableAdapter.U pdate(lngedientiRicettaDataTable dataTable)
in RicetteVB.Ricette.RicettaBindingNavigatorSaveltem_ Click(Object sender, EventArgs e)"
I will appreciate any help to understand the problem.
Private Sub Ricette_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DS = New RicetteDataSet
Me.IngedientiRicettaDataGridView.Visible = True
If RiceID = 0 Then
RiceID = 0
IngredientiBindingSource.DataMember = "Ingedienti"
IngredientiBindingSource.DataSource = DS
TipoCotturaBindingSource.DataSource = DS
TipoCotturaBindingSource.DataMember = "TipoCottura"
CategorieBindingSource.DataMember = "Categorie"
CategorieBindingSource.DataSource = DS
UmBindingSource.DataSource = DS
UmBindingSource.DataMember = "Um"
Me.RicettaBindingSource.DataSource = DS
Me.RicettaBindingSource.DataMember = "Ricetta"
Me.RicettaBindingSource.Position = pos
IngredientiRicettaBindingSource.DataSource = RicettaBindingSource
IngredientiRicettaBindingSource.DataMember = "FK_IngedientiRicetta_Ricetta"
Catch nhex As InvalidOperationException
Catch ex As Exception
Err(ex, "Form Load" & Me.Name)
'----- Saving IngedientiRicettaDatagridView to IngedientiRicetta SQL Table-----
Private Sub BtnSalvaIngredienti_Click(sender As Object, e As EventArgs) Handles BtnSalvaIngredienti.Click
Catch nhex As InvalidOperationException
Catch ex As Exception
'Adding new row to IngedientiRicettaDataGridView
Private Sub IngedientiRicettaDataGridView_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) Handles IngedientiRicettaDataGridView.DefaultValuesNeeded
.Cells("IngredienteRicettaQtaDataGridViewTextBoxColumn").Value = 0
.Cells("IngredienteNome").Value = String.Empty
.Cells("IngredienteRicettaNoteDataGridViewTextBoxColumn").Value = String.Empty
Catch ex As Exception
thing that is strange for me:
in the dataset the constraint between 'Ricetta' and 'IngedientiRicetta' is:
INSERT or UPDATE= None
While in SQL we have
INSERT or UPDATE=Cascade
DELETE = Cascade
In any case I don't give a value to IngedientiRicettaID (key and identity)
Also in datagridview is not added as column.
But why all is good in one SQL server (developer) and wrong in another server (SQL EXPRESS)?
NOTE:The bound IngedientiDataGridView with columns has been created at Design Time
Last Visit: 31-Dec-99 18:00 Last Update: 4-Aug-21 10:14