|
I have a text box and a crystal report viewer in a windows form.
As user types in some text in text box, it should immediately display in report viewer. I have done this, but I have problem here, that is "If user types too quickly then refreshing of the preview screen is fine, but if user type slowly then text is lost"
I am not able to find a solution to this problem.
I tried with multithreading, with timer but could not able to implement it.
can someone please help me in this?
Thanks in advance
|
|
|
|
|
What? The text in the TextBox? Are you clearing it? Why?
At any rate, I don't think I would implement it that way. I would have the user enter the text and then press a Button to get the preview. I find producing unnecessary previews and such to be wasteful and irritating.
|
|
|
|
|
Mahesh_Blr wrote: "If user types too quickly then refreshing of the preview screen is fine, but if user type slowly then text is lost"
Can you not refresh your report in the text box's keyup/keydown event?
|
|
|
|
|
In my program, I have an array of numbers (total number of modules that can be connected to a tracker) and an array of sums (number of modules that has to be mounted on a roof surface).
Let's suppose:
int[] intConnectables = {24, 22, 20, 16, 12, 11, 10, 7, 6}
int[] intRoofSurfaces = {43, 38, 27, 11}
The script has to group the connectables so that every number is used and there are the groups so every total adds up. If there exists a valid combination, I put the system in a seperate set (in the end that set would contain all valid combinations).
e.g.
24+12+7 = 43 | 22+10+6 = 38 | 20+16 = 27 | 11 = 11
Afterwards, I'll have to know wich element of Connectables belongs to wich group (e.g. 22 belongs to the 2nd group wich adds up to 38).
Any ideas?
Thanks in advance!
modified on Wednesday, April 28, 2010 11:05 AM
|
|
|
|
|
Are you looking for the algorithm (subset sum?) or a way to get the group number back from an element (maybe use parallel arrays, or a dictionary if you're going to move the elements)?
Or something else?
|
|
|
|
|
Actually the algorithm. Each roof surface is oriented and inclined in a specific angle. The array I use is the grouping of the roof surfaces to these fields. The orientations and inclinations have to be transferred to the "connectables" afterwards to calculate generated power. That's why I have to know wich element of the intConnectables belongs to wich sum in intRoofSurfaces.
|
|
|
|
|
Can you use the connectables once per roof surface or just once (across all roof surfaces)?
For now I'm guessing the latter..
And you must use all of them?
You could maybe (in pseudo code):
(!!untested!!)
bool Solve(int i)
{
if (i == numberOfConnectables + 1)
return true;
for each RoofSurface
add Connectable[i] to the RoofSurface
if (RoofSurface.Sum <= RoofSurface.Target)
{
if (Solve(i + 1))
return true
}
remove Connectable[i] from the RoofSurface
endfor
return false
}
Just an idea, I'll go test it in a moment
|
|
|
|
|
Just once across all roof surfaces. In the end I need to know if the "puzzle" can be solved and -if so- wich connectable belongs to wich roof surface.
The array intRoofSurfaces contains the targets. The most important thing I need to know is if there is a possibility to divide the elements of intConnectables[] into n groups where n is the number of elements in intRoofSurfaces. If it proves to be possible, I need to know for every element in intConnectables[] to wich element of intRoofSurfaces[] it is connected.
I know, I'm being a little picky right now, but I really need to get it before I can code the next parts of my program.
The following is just informative, so don't take it in consideration when posting your ideas just yet... Therefore I'll put it in a smaller font.
I have a set with a whole bunch of combinations (arrays intConnectables[]). Every combination will be checked. A few steps later, the roof surfaces are ungrouped and I'll have to do a reversed algorithm. More or less, because a connetable will now be usable across roof surfaces.
e.g.
The grouped roof surface has to contain 28 modules and it exists of 3 roof surfaces: 15, 7 and 6 modules. There are 4 connactables assigned, 9, 8, 6 and 5 modules.
intConnectables[] = {9, 8, 6, 5}
intSeperateRoofSurfaces[] = {15, 7, 6}
Then I would have to get a result like this:
9 + 6 = 15 | 7 [from 8] = 7 | 5 + 1 [from 8] = 6
So the connectable of 8 has been split into 7 and 1.
Just informative...
|
|
|
|
|
Ok can you verify this please?
Connectables = { 24, 22, 20, 17, 12, 11, 10, 7, 6 }
RoofSurfaces = { 43, 38, 37, 11 }
Answer = yes, { 0, 1, 2, 2, 0, 3, 1, 0, 1}
|
|
|
|
|
Works like a charm! Thanks
|
|
|
|
|
Tested, works (for the problem as I understood it, anyway):
static class Solver
{
static int[] RoofSurfaces, Connectables, Sums, AssignedTo;
public static int[] Solve(int[] connectables, int[] roofSurfaces)
{
RoofSurfaces = roofSurfaces;
Connectables = connectables;
Sums = new int[roofSurfaces.Length];
AssignedTo = new int[connectables.Length];
for (int i = 0; i < AssignedTo.Length; i++)
AssignedTo[i] = -1;
if (solve(0))
return AssignedTo;
return null;
}
static bool solve(int i)
{
if (i == Connectables.Length)
return true;
for (int k = 0; k < Sums.Length; k++)
{
Sums[k] += Connectables[i];
AssignedTo[i] = k;
if (Sums[k] <= RoofSurfaces[k])
{
if (solve(i + 1))
return true;
}
Sums[k] -= Connectables[i];
AssignedTo[i] = -1;
}
return false;
}
}
If there is a solution, it returns an array with the number of the RoofSurface that each Connectable is in, otherwise it returns null.
edit: it may not be the coding style you like etc etc, I'm not trying to set a good example here, I just made this in a couple of minutes to Just Work without looking at the style too closely.
The -1's were just useful for debugging - you don't actually need them (the variable i already determines which entries are valid)
modified on Wednesday, April 28, 2010 11:03 AM
|
|
|
|
|
I don't mind the coding style, mine isn't perfect as well. But at least I have a good idea of how to solve this thing...
Big thanks!
|
|
|
|
|
You're welcome
|
|
|
|
|
I fail to see any logic between the two arrays.
If the arrays are small you could use the index as number and the value as groupnumber. Better would be to have a class with two integers and put that in an array somehow.
No matter how you do it, you'll have to define some logic between the numbers and the group there in.
V.
|
|
|
|
|
i fill combobox through datasource but at form load i have to show "None" default value of combobox. how i do it??
|
|
|
|
|
try setting it's Text property. Being bound you can not add Items programatically but the
Text property should work.
|
|
|
|
|
Add a "None" item to the collection before you bind it to the control?
modified on Wednesday, April 28, 2010 12:00 PM
|
|
|
|
|
items collection can not be modified when the datasource property is set...
|
|
|
|
|
not to the comboboxitems.
Add "None" to the dataset or whatever underlying collection the combobox is bound to.
|
|
|
|
|
Yes you can:
public bool AddItemToComboDataSource(ref ComboBox box, string displaymember_value, string valuemember_value)
{
bool succes = false;
try
{
DataView view = (DataView)box.DataSource;
DataRow row = view.Table.Rows[0];
row[0] = displaymember_value;
row[1] = valuemember_value;
view.Table.Rows.Add(row);
box.DataSource = view;
succes = true;
}
catch (Exception ex)
{
errormsg = ex.Message;
}
return succes;
}
Which is a little cheating, probably, but it works.
V.
|
|
|
|
|
hi
i want to run an dshow an application in my project and limit it to my MDI form !
can i do it? if yes how can i?
|
|
|
|
|
The answers here[^] should get you well on the way, if they work.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi
im new in codeproject i would begin programming a project in c# with web devlopper
if you have any document for begining and implementing a project with a web service and IIS and SQL server
finaly
thanks you very match
your friend
ABDELHAMID
from Morrocco
|
|
|
|
|
Welcome,
but you couldn't have gotten more things wrong in your post if you'd tried really hard.
1) All bold
2) Non specific question
3) Irrelevant subject
|
|
|
|
|
thanks you i would begin programin a n tier project
|
|
|
|