|
levanduyet_vn wrote: I just want to get help Then you need to explain what your problem is.
|
|
|
|
|
levanduyet_vn wrote: I want to buy Data Access Layer component for my project. Why? There are many free ones available and it's incredibly trivial to write your own DAL.
This space for rent
|
|
|
|
|
Dear Pete,
Please give me the links that I could refer.
Thanks,
LVD
|
|
|
|
|
In the time you took to write that, you could have used Google[^] to find examples. There's a CP one there that shows a simple DAL.
This space for rent
|
|
|
|
|
Hi Pete,
Sure, I have google but I need to have a advise from who have used it.
LVD
|
|
|
|
|
maybe this one[^] works for you?
It is very simple and quick to use. It is also very stable.
It might be limited in possibilities, but using the code you can extend as much as you want.
Hope this helps.
|
|
|
|
|
|
Use Entity Framework and its free, this is just a abstracted data layer.
<tag>I have no tag
|
|
|
|
|
Dear All,
I have tried to amend existing connection string from file App.config and save it back.
The code as following:
<pre lang="c#">
const string DEFAULT_CONNECTION_KEY = "defaultConnection";
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection("connectionStrings");
sConName = ConfigurationManager.AppSettings[DEFAULT_CONNECTION_KEY];
config.ConnectionStrings.ConnectionStrings[sConName].ConnectionString = sConCrypt;
config.Save(ConfigurationSaveMode.Full, true);
ConfigurationManager.RefreshSection("connectionStrings");
But it show an error.
"An error occurred creating the configuration section handle for log4net: Could not load file or assembly 'log4net' or one of its dependencies. The system cannot find the file specified.
F:\...\bin\Debug\PuFoamControl.vshost.exe.Config line 4"
Anyone can help me.
Thanks,
LVD
|
|
|
|
|
That means that your app.config contains a section for configuring log4net, but the log4net dll is not present in the folder or in the GAC. Make sure it is available, or remove the log4net specific sections manually from your app.config.
|
|
|
|
|
Thank you Hiller.
I delete this section and it run ok.
LVD
|
|
|
|
|
Hi!
I've a bi-dimensional array of labels (a lot of them) so when I make change properties the render is to slow.
My solution (I thought) was make the panel invisible at the init time and then visible when the job is completed but it's visible before the job is completed! I think my app is multithreaded for default.
using System;
using System.Windows.Forms;
namespace Program
{
public partial class Form1 : Form
{
MySqlConnection cn = new MySqlConnection();
iTextSharp.text.pdf.PdfWriter writer;
const int panelHeight = 730;
const int panelWith = 1070;
private Label[,] lbs = new Label[70,50];
public Form1()
{
InitializeComponent();
initBoard();
}
private void initBoard()
{
panel1.Size = new Size(panelWith, panelHeight);
panel1.Visible = false;
anel1.BackColor = SystemColors.ControlText;
int cc, ff;
for (int c = 0; c < 70; c++)
{
cc = c * 15;
for (int f = 0; f < 50; f++)
{
ff = f * 20;
Label lb = new Label();
lbs[c, f] = lb;
lb.Size = new Size(15, 20);
lb.Font = new System.Drawing.Font(label1.Font.Name, 12, FontStyle.Bold);
lb.Location = new System.Drawing.Point(cc + 10, ff + 10);
lb.Parent = panel1;
lb.ForeColor = Color.WhiteSmoke;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int c = 0; c < 70; c++)
for (int f = 0; f < 50; f++)
lbs[c, f].Text = (f % 10).ToString();
panel1.Visible = true;
}
}
}
Any ideas ?
Of course I'm just starting.... this is not the way I should program
modified 29-Feb-16 12:27pm.
|
|
|
|
|
Pablo Bozzolo wrote: this is not the way I should program Very true, 3500 labels to update is far too many. You need to rethink your design, and what you are trying to achieve with this program.
|
|
|
|
|
Of course I know that I want to do (instead of numbers some characters will be placed) and the number of 3500 is not optional.
I'd like to be able to add an event handler to each label in a future so I don't want to use a Richtext or something different to a bunch of controls.
Maybe I can use a GridView (I've no experience in Visual Studio), ...... I hope it will help because If put vertical scrollbar it freeze the GUI because the high number of controls in the Panel.
The question here is WHY I can see when labels are filled if the Panel is invisible!
|
|
|
|
|
If you tell us your ultimate goal here (why do you think you need 3500 labels?) someone might be able to suggest a way to achieve it in a "less strange" way
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Ok
3500 characters are the number of characters I need to see at once in my program to do something with them.
modified 29-Feb-16 16:15pm.
|
|
|
|
|
Why not a single multiline-TextBox? You could put some spaces between the characters to give it a table-like appearance. Otherwise a DataGridView.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thank you for your answer
I was thinking too to do something like to comment with a multiline-TextBox, so I think I will decouple things to be able to switch easily.
|
|
|
|
|
If your "program" needs to see the 3.5k characters, why are you displaying them to the user. Your ability to manipulate the data is not dependent on the UI. You UI should be collecting user input and displaying results.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Pablo Bozzolo wrote: The question here is WHY A more important question is: what problem are you actually trying to solve? The design of your application goes against most rules of development.
|
|
|
|
|
Hi,
WinForms (or any other GUI technology) wasn't designed to handle that many controls, you need a very different approach.
I suggest you look at my Sokoban article[^], which describes a board game of arbitrary size. It uses a single control (a Panel), that acts as a matrix of controls: it performs all drawing explicitly ("userdrawn"), and handles events collectively, i.e. most event handlers start with code to decide which cell of the board is being accessed. It isn't as easy as having a matrix of controls, but once you know how to identify the matrix cells, it becomes rather easy...
|
|
|
|
|
There are several things you could do to make your existing code run a bit faster, but I'm going to join the choir here singing that 3500 Labels are too much, and you need to change horses.
I think you will be surprised, as I was, how much you can do with making a grid by painting on a Panel; here's a screenshot from a 15x10 grid that I draw on a Panel: [^].
The "highlighted cell" you see is the result of a click on the Panel: that's a Label, sized to the cell-size in this example, that pops-up directly over the "cell" clicked; it presents information about the row,column address, and the cell id number.
The color scheme is generated algorithmically, stored in a data structure, and then mapped to the cells in the Paint EventHandler; this data is also computed in advance: the set of Rectangles of all cells in the grid; the set of strings painted into each cell. Of course, all brushes and pens are created outside the Paint EventHandler. The idea ... an obvious one ... is to get all possible computation, and whatever-creation, out of the Paint EventHandler.
Hit detection is very easy:
private void Grid1_MouseDown(object sender, MouseEventArgs e)
{
currentRow = e.Y/rowHeight;
currentColumn = e.X/columnWidth;
cellId = currentRow*columnCount + currentColumn;
PopLabel.Text = string.Format("{0},{1} {2}", currentRow, currentColumn, cellId);
PopUPPanel.Location = new Point(currentColumn*columnWidth, currentRow*rowHeight);
} I did try cranking up this prototype to 50 rows of 70 columns, and it drew very quickly (i7-4970k machine, Win 8.1, 8 gigs memory at present for testing purposes). But, I have no idea what to do with 3500 cells
«In art as in science there is no delight without the detail ... Let me repeat that unless these are thoroughly understood and remembered, all “general ideas” (so easily acquired, so profitably resold) must necessarily remain but worn passports allowing their bearers short cuts from one area of ignorance to another.» Vladimir Nabokov, commentary on translation of “Eugene Onegin.”
|
|
|
|
|
Good Morning
I have imported data into datagridView. The datagridView table has the following columns with the following meaning:
Date -Date when a particle was analysed.
Time -Time particle was analysed.
Analyzer - What analyzer was used to analyze the particle
Channel - What channel on the above mentioned analyzer was used
Sort - Is the classification of the particle, i.e "1" =concentrate; "0" = discard
H1 - H3- Measured values.
delay - how long the particle was measured for.
In excel I use sumifs or countifs functions to sort my data and calculate the weighted average H1 value for Analyzer 1. how do I go about and do this in c#
|
|
|
|
|
For a start, I wouldn't attempt to analyse the data based on it being in a DGV. If I were doing this, I would do all the work against a bindable collection and bind that to the DGV. To answer your question, you're going to have to write some mathematical analysis functions - no one's likely to just give you this here in a forum answer. If you Google, you should be able to find some suitable implementations that you could analyse.
This space for rent
|
|
|
|
|
You have to write the code yourself that does the calculation you want. You're probably setting the DataSource of your DataGridView to a DataTable, right? Use that DataTable also for your calculations. It's more convenient to handle than a DataGridView.
There are two options:
The traditional way: Loop over the rows in the DataRow-collection of the DataTable, read the values of the columns that are required for your calculation and then do the actual calculation. This would be a sample where I assumed double as the data type of your column "H1" and "some integer type" for the "Analyzer"-column:
double analyzer1Sum = 0;
int analyzerColumnIndex = myDataTable.IndexOf("Analyzer");
int h1ColumnIndex = myDataTable.IndexOf("H1");
foreach(DataRow row in myDataTable.Rows)
{
if(row[analyzerColumnIndex] == 1)
{
analyzer1Sum += row.Field<double>(h1ColumnIndex);
}
}
The LINQ way (assuming double as the data type of your column "H1" and int for the "Analyzer"-column):
int analyzerColumnIndex = myDataTable.IndexOf("Analyzer");
int h1ColumnIndex = myDataTable.IndexOf("H1");
double analyzer1Sum = myDataTable.AsEnumerable()
.Where(row => row.Field<int>(analyzerColumnIndex) == 1)
.Select(row => row.Field<double>(h1ColumnIndex))
.Sum();
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 29-Feb-16 13:49pm.
|
|
|
|