|
Hi friends
I am just a beginner , How to run a windows form in hidden mode ?
with warm regards
dyno
|
|
|
|
|
in the main entry programs (usually Main() under static class Program in vs2005) just write Application.Run(); without main form specified
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
On the Form_Load event type:
this.Hide();
This will hide the form as soon as it's opened by the user.
|
|
|
|
|
Is there an algorithm where i could get all the possible sequence?
Example: given is "abc"
where the possible sequence are:
"abc"
"acb"
"bac"
"bca"
"cba"
"cab"
|
|
|
|
|
Hi,
Silvyster wrote: Is there an algorithm where ...
Yes there is. In fact there are many. It is a nice occasion for
a recursive one: to find a valid combination permutation of N symbols, first choose
the leftmost symbol (a foreach loop could do that), then calculate the
remaining collection and solve the problem for that smaller collection
(with N-1 symbols) by recursion.
If you keep the symbols ordered in some way (say alphabetical) the nice
side-effect is all combinations permutations will come out in the same (alphabetical) order.
And recursion is appropriate since the number of combinations permutations grows exponen-
tially with the word length, i.e. your patience will run out long before
you get a stack overflow.
modified on Friday, October 31, 2008 8:31 AM
|
|
|
|
|
What you are looking for is an algorithm for permutations.
Go forth and search the web.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
right.
|
|
|
|
|
Hello there,
Whenever i say , "ok, we can solve this by declaring one bool variable (flag) and checking true/false" , my architect says "no flags please!!". Any thoughts why flags not recommended? is it not recommended best practice?
Thanks
|
|
|
|
|
Member 2324483 wrote: "ok, we can solve this by declaring one bool variable (flag) and checking true/false" , my architect says "no flags please!!". Any thoughts why flags not recommended?
Huh? Your architect needs to get his head checked out. There's nothing wrong with using flags for the most part.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
if a variable can have only two values it is perfectly OK to use a bool which is either true or false.
As an alternative you can define your own enum with two (or more) more meaningful values.
You can see the difference this can make in this hypothetical method call:
TextWriter wr1=File.CreateText("myFile1.txt", true, true, false, true, false);
TextWriter wr2=File.CreateText("myFile2.txt", FileMode.Write, FileShare.None, FileCreate.NoOverwrite,
FileCompression.Off, FileArchive.No);
The first line is error-prone for the programmer and a mystery for all readers and can be understood only
by checking something else (the documentation, Intellisense, whatever); the second line is self-explaining
by not using boolean flags.
|
|
|
|
|
Luc Pattyn wrote: As an alternative you can define your own enum with two (or more) more meaningful values.
The boolean version 2.0 springs to mind...
WTF: What is truth?[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I think that your architect has had some traumatic experience involving flags. There is nothing inherently wrong with using flags. They can of course be used in the wrong place or overused, but that can be said about anything.
The framework has a lot of exampels of flags, most of them working just fine. The Visible flag, for example, which is used in every control.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks guys for giving good explanations. However the explanation given by luc pattyn makes more sense. Thanks luc. May be thats the reason he (my architect) says "no flags" to make the code more expressive and less error prone.
|
|
|
|
|
Another point worth noting about using flags, especially as instance variables, is that it is important to record state changes. Subsequent changes to the code can often introduce new points of state change that impact the flag, but do not update the flag.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I am trying to fill a combobox that is in a datagrid with values. The code compiles fine, but when it generates the datagrid it gives a error. "System.ArgumentException: DataGridViewComboBoxCell value is not valid". Any ideas what I am doing wrong?
DataGridViewComboBoxCell colComboCell = new DataGridViewComboBoxCell();
colComboCell.Items.Add("0");
colComboCell.Items.Add("1");
colComboCell.Items.Add("2");
colComboCell.Items.Add("3");
dataGridTicketTypes.Rows.Add(EventTicketPrice_ID, colComboCell);
|
|
|
|
|
You can try the following code assuming that the comboBox column is named valueColumn:
DataGridViewColumn valueColumn = new DataGridViewColumn();
dataGridTicketTypes.Columns.Add( valueColumn );
DataGridViewRow row = new DataGridViewRow();
DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
cell.Items.Add("0");
cell.Items.Add("1");
cell.Items.Add("2");
cell.Items.Add("3");
valueColumn.CellTemplate = cell;
int rowIndex = dataGridTicketTypes.Rows.Add( row );
row = dataGridTicketTypes.Rows[ rowIndex ];
Hope it helps.
If you have any question contact me.
|
|
|
|
|
The code you provided did add the items to a dropdown menu, however it added a new column in which it added this data which I want to specify it as I am adding values.
1. Create a new form
2. Add a datagridview1 to the form
3. add two columns to the data grid (IDColumn, valueColumn)
4. Add a button to the form which will insert a record
5. When you click on the button it should add one row to the DataGrid by using something like below (but that actually works).
DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
cell.Items.Add("0");
cell.Items.Add("1");
cell.Items.Add("2");
cell.Items.Add("3");
dataGridView1.Rows.Add("test", cell);
|
|
|
|
|
You can skip the first two lines :
DataGridViewColumn valueColumn = new DataGridViewColumn();
dataGridTicketTypes.Columns.Add( valueColumn );
|
|
|
|
|
I already had those skipped. My code looks like this which still does not add information to the drop down menu.
private void button1_Click(object sender, EventArgs e)
{
DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
cell.Items.Add("0");
cell.Items.Add("1");
cell.Items.Add("2");
cell.Items.Add("3");
dataGridView1.Rows.Add("test", cell);
}
|
|
|
|
|
Here is what I am trying to do.
I have treeview that is full of a family tree.
Example
parent1
-spouce1
-kid1
-secondkid1
parent2
-kid2
parent3
-spouce3
-kid3
parent4
(but I don't really know how many parents and kids there are.
So, now what I want to do is randomly match up each person with someone else, but not someone in thier own node. For example, I don't want parent1 to get matched up with his spouce or kids, but he would be fine matched up with parent2 or his kid.
My brain is about mush right now and I am not thinking of how to do this, though there must be a simple way.
My original idea was to put everything into arrays. Then choose the longest array and randomly chhose another array then randomly choose a member of that array to match up with the first person, then remove both people from the arrays and calculate the longest array again and repeat until there is no one left. But implementing the idea seemed more complicated and I thought there must be an easier way, no?
|
|
|
|
|
If you want it to be more random you could use your original idea but with a random number generator to determine which array to look at rather than just selecting the longest array. Another idea would be to put everything in a single array and just use the random number generator to give a random index into the array and if the item in the index is in a different family, you've got a hit otherwise get another index from the random number generator.
List<int> peopleUsed = new List<int>();
Random r = new Random();
int person1Index, person2Index;
person1Index = person2Index = 0;
while(peopleUsed.Count < people.Length)
{
if(!peopleUsed.Contains(person1Index))
{
do
{
person2Index = r.Next(0, people.Length);
}
while(peopleUsed.Contains(person2Index) && !peopleAreInSameFamily(person1Index, person2Index));
peopleUsed.AddRange(new int[] { person1Index, person2Index });
}
person1Index++;
}
Keep It Simple Stupid! (KISS)
|
|
|
|
|
the problem I worry about with that is if you don't start with the longest list, then you might end up at the end with only members of one family
|
|
|
|
|
I am able to open uncompressed TIF files using
Bitmap objImage = new Bitmap(ImagePath);
but when I try to read compressed tif (JTIF) it gives me error.
Is there any way I can convert compressed tif to uncompressed?
Thanks.
Niks
|
|
|
|
|
NAMhatre wrote: Is there any way I can convert compressed tif to uncompressed?
Not using anything dependant on GDI+, no. GDI and GDI+ do not support LZH compressed (read JPG) TIFF files. You'll have to use a third party library to handle those files or an external tool to convert the files to uncompressed TIFFs.
|
|
|
|
|
Dave Kreskowiak wrote: LZH compressed (read JPG) TIFF files
Ummmmm LZH is a lossless compression algorithm, JPEG uses a lossy algorithm.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|