I have a productlabel (.lbl file crated with NiceLabel).
Using Wingforms (c#) I want to open this label file and get the fields so I can assign data (from my database) to them and then save the label.
So in the end, I have a label with values that I can print.
Is a way t do this?
Edit: If possible, it would be awesome to also show the finished label in the form, to see if all values are in correct place.
Related
I'm in the process of creating a front-end Windows Forms application, which will have multiple uses. One of those uses will be to allow the end-user to manage the contents of a database table.
At the moment, my form contains a DataGridView object which uses a DataTable as its source. That datatable is populated from a stored procedure which selects every row from the table based on criteria specified by the end user. I want to put code into the DataGridView which will look at the row that's been selected by the user, and will populate a series of text boxes with the details from that row.
I want to avoid hard-coding a text box for each column in the DataGridView, since it's highly possible that in the future I might add columns to the underlying stored procedure. Therefore, my plan is that the first time the user selects a row, the application would dynamically create a text box for each column, size that text box appropriately (both height and width) and add the appropriate labels.
So far, the code I've written creates a brand-new DataTable, and adds columns to store the following information about each column in the DataGridView:
The actual name of the DataGridView column;
The name that I wish to give to the associated label;
The text that I wish to assign to the associated label;
The top and left positions of the associated label;
The name that I wish to give to the associated text box;
The value that I wish to display in the associated text box;
So far when the user initially clicks on a row, everything is working well: the text boxes get created in a vertical column, with the associated label to the left of each text box and the appropriate value displayed in each one. Each text box has its width dynamically set based on the contents of that text box so that everything can easily be seen.
The difficulty comes when the user changes from one row of the DataGridView to another. The code that runs to create each control looks like this:
if (pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Remove(txtCurrent);
}
if (!pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Add(txtCurrent);
}
When the code first runs, all seems to be fine. However, if it gets fired a second time (at which point it should remove and re-create the control) it doesn't seem to detect the prior existence of the control and simply creates a second copy of it in the form.
For information, the form I'm building has multiple uses which are dictated by a series of buttons. Therefore, I'm creating the controls for this particular use inside a Panel (pnlManageJobManagerOutcomes). I'm completely stumped as to why the code doesn't spot the existence of those controls during subsequent executions.
TIA
I've figured out a way to do it, which may seem to be clunky but which seems to work.
Since it doesn't appear that I can check to see whether the Panel I'm working with Contains the field name, I've written a method which will loop through the controls in that Panel and return a count of the number of instances of that control in the Panel's Controls array. If the method returns a 0, this means the Control doesn't exist in that Panel and I can go ahead and create it.
I have a winform app that has 25 buttons that increase a counter on 25 labels above each button. What would be the best way to use a save button on click event to save the current values of the labels to a comma-delimited text file such that the first save creates the file and each additional save overwrites it?
Info: Assume the labels are named label1-label25 for simplicity, the text file will be named appDataFile, and that the save button will be named button26.
Example: On initial save, the winform app will create appDataFile and populate 25 values separated by commas. On any additional save it will then take the current value (let's say label1 was 5 already and its new value is 7) and will then overwrite the data in the text file and be left still with 25 values but the first being label1 will now be 12
I have an ASP.net 4.5 text box with 5 rows. When I save the below data to my table it does not take in consideration that there are line breaks.
Example:
Hello my name is Mike!
How are you?
Please can you help?
When saving this data to my table it of course save it like this below and it will be displayed like this again if I populate my website with this value.
Hello my name is Mike!How are you?Please can you help?
But I want it to be displayed with the line breaks as the way it was written in the first place.
The thing is, I do not want to make use of a custom form item because then the user will be able to copy and paste all html from another website in and I do not want that.
Any idea how this can be done without using a plugin such as below where the user will be able to copy and paste data into?
To populate your text box from the database try;
TextBox1.Text = someText.Replace("\r\n", Environment.NewLine)
For Label
Label1.Text = someText.Replace("\r\n", <br />)
Alternatively you could save the data to your database with the
someText = TextBox1.Text.Replace("\r\n", "<br />")
Although this approach may not be appropriate if the database is also used elsewhere.
My application is a form based application, having multiple textboxes that can be filled. Some textboxes however is optional and a checkbox is included to toggle if it should be included.
Now I would like to save the progress of the form so it can be opened later for further editing. I am saving this file as an .xml. Saving the textboxes I have no problem with, but what is the best way to save the state of the checkboxes to the .xml file, so it can be loaded later?
I can simply use - string s = Bool.ToString();.
It does work but when working with a lot of checkboxes it can become a long process. I have a class that handles the saving of the .xml file. Is there a way to add more then one checkbox to a list then parse the "true/false" value to the class as an array of Bool[]?
Checkbox-state is nothing else than an Boolean? -> Nullable bool. You can simple serialize it using an xmlserializer or write it manually to the file:
string s = checked.ToString();
and to parse it:
bool checked = Boolean.Parse(s)
I would like to do something like simple data binding in Windows Forms, but in Web Forms. So I would like to get data from a column NAME from table CATS (one row) and display in on website in text box (input type='text') and next I would like to click on "save" button to save this data to database doing an update.
Could you please give me a short snippet of how should I do it to work and get understanding of how does it go?
Really easy updating can come through the detailsview control: https://web.archive.org/web/20211020133929/https://www.4guysfromrolla.com/articles/050207-1.aspx