|
try doing the same function you do but backwords.
i.e: insted of:
for (int i = 0; i < n; i++)
write:
for (int i = n-1; i => 0; i--)
or
for (int i = n; i > 0; i--)<br />
i-1;
etc...
another way is to use a DataSet to arrange the stuff up... (may be longer)
that's all I can think of (without looking at properties etc...)
yours, NaNg.
|
|
|
|
|
hi JMichael2468!
Instead of using the ListBox's Items.Add method, use the Items.Insert method.
then pass a zero value in the index parameter so it will be added on top of the collection.
i tried it and it works fine with me.
hope this helps!
microsoc
|
|
|
|
|
|
Hey all... I know a little C#, I've been working with it for 2 years (still at school, 11th grade), I'm pretty expirienced but still I don't know alot... I'm building all my programs on VC# express, which as you know, has built-in publisher, with built-in installation, well, I wanna do a few things out of the small box it shows me, so here are some questions that I remember now, that I would like answers to them, and appriciate if you would answer, or give me a link for it:
1. How can I register my program in such a way, that the computer will know that files with endings such as what I want(i.e .ysl) will have an icon that I want?
2. How can I register my program in such a way, that I can put an option of "Start with Windows startup"?
3. What is the BEST way to make sure that my program is only run ONCE in the computer, and that no-one will be able to open another copy will the first one is running?
4. How can I open a process (System.Diagnostics.Process), and make sure it's an internet explorer program, such as IE or NetScape no-matter to the program he use (IF statements will be accepted), and open it in a URL I want?
5. How can I tell who implements ICryptoTransform (System.Security.Cryptography.ICryptoTransform) without checking at Microsoft's MSDN for each and every one? and what is the best way to encode (Crypt) my code (what is the best ICryptoTransform implementing class to do it)?
6. Where can I find default icons such as SaveAs... (three discates), Save (one discate), open (folder), new (page) etc...?
well... that's enough for now... if I'll remember some more I will ask...
THANKS IN ADVANCE FOR ALL THE ANSWERS!!!!
-- modified at 15:51 Monday 8th May, 2006
|
|
|
|
|
sorry for the multiple posting, the site said and error and I thought it didn't post it, if the admin can erase one please, but leave one also, that would be lovely ...
thanks...
|
|
|
|
|
This happens from time to time.
You can erase your postings on your own. There is a delete link at the right side of bottom edge.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
3. Search for "single instance" here on Code Project. There are some articles covering this topic. (By the way this should be done everytime before asking a question in the forum).
1. I think there are articles too which cover this topic.
2. Where do you want to put this option? If you want to start your application with windows startup, simply create an appropriate link in the Autostart folder of startmenu.
4. Process.Start("www.troschuetz.de"); //Opens URL with standard browser
6. Not sure, but maybe searching for "*.ico" on C-partition brings some results. Also googling for "ico" or "icon" and "SaveAs", "Save" or ... may be worth a try.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
1. Create some registry entries under HKEY_CLASSES_ROOT:
This can all be done programatically, but it takes some work. Look at the Microsoft.Win32 namespace for registry manipulation functions.
1) Create a key by the name of the file extension you want
2) Set the default attribute of this key to a word that describes your program. It's name doesn't really matter.
3) Create a key by the name of the word you decided on in step 2.
4) Create some subkeys: 'DefaultIcon' and 'shell'
5) Set the default attribute of the DefaultIcon key to the path of your icon. If you want to use the the same icon
as your executable, do something like this: <code>c:\code\mysupercoolapp\exefile.exe,0</code>
6) Create a 'open' subkey under 'shell' and a 'command' subkey under open
7) Set the default attribute of the 'command' key to the path of your program (include the %1) <code>c:\code\mysupercoolapp\exefile.exe %1</code>
8) Restart
9) When a file with the extension you've picked is double-clicked, your application will run.
The first argument will be the path of the file.
2. You can put a link in the startup folder of the start menu, or add a registry entry to either
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
(if you want it to run whenever the computer starts)
or
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
(if you want it to run whenever only the current user logs on)
3. As the other post-er said, search for "single instance"
4. System.Diagnostics.Process.Start("http://www.myurl.com"); will open the url in the default web browser
5. I should read up on cryptography
6. They are in a zip file in Visual Studio's program folder:
C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\VS2005ImageLibrary.zip
(or similar)
Hope this helps,
DigitalKing
|
|
|
|
|
thank you very very very very very very very very much!!!
Both of you!
|
|
|
|
|
the Process.Start("http://..."); method is opening the URL in the already opened browsers, how can I turn it to new browsers?
|
|
|
|
|
There's no good way to accomplish this, as it is the user's preference.
For example, in firefox, the user can select whether to load newly opened pages in the current tab, or a new tab.
|
|
|
|
|
Hey all... I know a little C#, I've been working with it for 2 years (still at school, 11th grade), I'm pretty expirienced but still I don't know alot... I'm building all my programs on VC# express, which as you know, has built-in publisher, with built-in installation, well, I wanna do a few things out of the small box it shows me, so here are some questions that I remember now, that I would like answers to them, and appriciate if you would answer, or give me a link for it:
1. How can I register my program in such a way, that the computer will know that files with endings such as what I want(i.e .ysl) will have an icon that I want?
2. How can I register my program in such a way, that I can put an option of "Start with Windows startup"?
3. What is the BEST way to make sure that my program is only run ONCE in the computer, and that no-one will be able to open another copy will the first one is running?
4. How can I open a process (System.Diagnostics.Process), and make sure it's an internet explorer program, such as IE or NetScape no-matter to the program he use (IF statements will be accepted), and open it in a URL I want?
5. How can I tell who implements ICryptoTransform (System.Security.Cryptography.ICryptoTransform) without checking at Microsoft's MSDN for each and every one? and what is the best way to encode (Crypt) my code (what is the best ICryptoTransform implementing class to do it)?
well... that's enough for now... if I'll remember some more I will ask...
THANKS IN ADVANCE FOR ALL THE ANSWERS!!!!
|
|
|
|
|
I have a need to take schemas of any kind and have generic code that will "walk" through the stuff and come up with the results that look similar to the XSL view in VS2005. While I don't need to create the graphic view....I do need to lump together each element, its' name, and the child nodes and attributes associated with that element. I loaded up a schema object and was able to see the first node, but walking deeper into it is a stumbling block right now. Any suggestions / articles would be appreciated.
-- modified at 15:06 Monday 8th May, 2006
|
|
|
|
|
I am using Asyncallback in .net CF development in a button_click event. There is no problem when I complie and deploy the program, but as I click the button to start the event, error occured. The message is 'An unhandled exception of type 'System.NotSupportedException' occurred in System.Windows.Forms.dll', and it stopped at 'application.run(new form())' I used the begininvoke to start the callback, and endinvoke to get the result. I used ppc 2003 emulator, and vs2005. Thanks for your help.
Here comes part of my code:
private delegate int CalcDelegate(int input1, int input2, ref string strResult);
CalcDelegate mDeleg;
private void button1_Click(object sender, System.EventArgs e)
{
mDeleg = new CalcDelegate(Calc);
int input1 = Convert.ToInt16(textBox1.Text);
int input2 = Convert.ToInt16(textBox2.Text);
string strResult = null; // dummy parameter
AsyncCallback cb = new AsyncCallback(CalcCallback);
IAsyncResult ar = mDeleg.BeginInvoke(input1, input2, ref strResult, cb, null);
Thread.Sleep(1000);
}
private void CalcCallback(IAsyncResult ar)
{
string result=null;
int output = mDeleg.EndInvoke(ref result, ar);
textBox3.Text = output.ToString();
}
|
|
|
|
|
This is not the first time I've seen this, either...
I create a RichTextBox, and I catch some keydown events. I want to catch CTRL-I, CTRL-B, and CTRL-U for changing selected text (italic, bold, and underline). It works fine with CTRL-B and CTRL-U, but when I hit CTRL-I, the richtextbox inserts tabs in there, too. For example (if you were to open the RTF files in Notepad), this line:
... bla bla bla ...
turns into:
... \i\tab bla bla bla \i0\tab ...
instead of:
... \i bla bla bla \i0 ...
And, if I do it right, it seems to replace the selected text with an italicized tab.
Any ideas?
-Daniel
-- modified at 14:25 Monday 8th May, 2006
|
|
|
|
|
I believe you want to catch the KeyDown or KeyPress event (not sure which one). One of these events lets you tell the event handler that you have processed the key and this prevents the underlying UI control from seeing it.
|
|
|
|
|
I currently am catching the KeyDown event. I'll see if setting the KeyEventArgs e.Handled to true helps at all...
-Daniel
|
|
|
|
|
Nope, no change. It still inserts a tab character. I thought it might have something to do with setting the rtfbox's AcceptsTab to true, but it does it whether it's true or false.
-Daniel
|
|
|
|
|
Well, I figured out a work-around, in case someone else gets as annoyed as I did at how the RichTextBox inserted tabs when it shouldn't.
I put in a global bool ("handled").
I have a KeyDown handler, and a KeyPress handler.
In the KeyDown, it sets "handled" to false, and checks for all the CTRL-[x] key strokes (where 'x' represents any other key on the keyboard).
If CTRL-I is pressed, "handled" is set to true.
Then, in the KeyPress handler, e.Handled is set to "handled" (meaningless for all the other CTRL-[x] keystrokes).
Basically, I had to tell the RichTextBox to ignore CTRL-I. I don't know why. I don't see a difference between CTRL-I and CTRL-[x], as far as the underlying control is concerned; and I don't see why CTRL-I is so special that the RichTextBox would trigger a tab-insertion on it and no other.
Oh well. It's fixed now. Thanks anyway!
-Daniel
|
|
|
|
|
You could also have overridden IsInputKey for RichTextBox and filtered out TAB characters.
Incidentally, the difference in Ctrl+I and Ctrl+{x} is that Ctrl+I is also the ASCII representation of tab (CHR 9). (You can open Notepad and press Ctrl+I in the text area; it tabs over just like you had pressed the Tab key.)
--
I've killed again, haven't I?
|
|
|
|
|
Wow, thanks, Office Lineman! I had looked into the IsInputKey, and I probably would have taken that route if I knew CTRL-I's relationship with the tab character.
By the way, I didn't know that (about CTRL-I being the keystroke for tab). That might make typing a tab character into web form text boxes a little easier!...
-Daniel
CodeProject rocks.
|
|
|
|
|
Hi..
I want to use the CmdLoadFromResource() method of ths speech SDK 5.1 to make the xml file that includes the Grammar embeded but i dont know how to use this method in C#.
This code shows how i used this method:
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long LoadLibrary(string lpLibFileName);
private void button2_Click(object sender, System.EventArgs e)
{
this.objRecoContext = new SpSharedRecoContext();
this.objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);
this.objRecoContext.State=SpeechRecoContextState.SRCS_Enabled;
grammar = objRecoContext.CreateGrammar(0);
int hModule=Convert.ToInt32(LoadLibrary("ReviewWinApp.dll"));
int langID=409;
grammar.CmdLoadFromResource(hModule,"tryRecog.xml","CFGGRAMMAR",langID,SpeechLoadOption.SLODynamic);
grammar.State=SpeechGrammarState.SGSEnabled;
grammar.CmdSetRuleIdState(1,SpeechRuleState.SGDSActive);
}
When i click this button i got the error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ReviewWinApp.exe
Additional information: The specified resource type cannot be found in the image file.
I am not good in COM programming.Could any one give me a C# code sample for using this method?
|
|
|
|
|
When the main window of a .NET Windows Forms app is partially occluded by other windows, clicking one of the app's exposed menu items correctly activates the form but doesn't display the menu.
I know this is in keeping with MS' new UI guidelines (as seen in Office 2003 apps), but I'd like my app to behave like an older style MFC app. I recall seeing an article/note that explained how to do this but don't seem to be able to find it. A pointer would be much appreciated.
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi everybody!
I have DataGridView whose sourse I set to a datatable with 4 columns
containing data. I then remove two columns, create a DataGridViewComboBoxColumn and DataGridViewCheckBoxColumn and insert this into the same location as the columns that were removed. I want to set as the selected value in the combo box of every cell in the DataGridView a specific value. I have done it, but once the debugger leaves the file with the code that executes this functionality, the values that were set in the combo box and check box are lost.
I don't know whether the problem is because I removed and then added these columns. At the end of the Load() method I have this line: dataGridView.AutoGenerateColumns = false; if I don't use it, the column that I removed appears again. Any idea about why the value of the DataGridComboBoxColumn is changed to null automatically and how to solve it?
Other thing is that if I change the values of the combo box in the datagridview and later I want to save them, when I get the values are not the ones I chose, but the values that I set at the beginning as the datasource of the datagridview.
This is part of the code I’m using:
private void FrmTestCases_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Path", typeof(string)));
dt.Columns.Add(new DataColumn("Category", typeof(string)));
dt.Columns.Add(new DataColumn("Include", typeof(string)));
dt.Columns.Add(new DataColumn("Description", typeof(string)));
dataGridView.DataSource = dt;
dataGridView.Columns.Remove("Category");
dataGridView.Columns.Remove("Include");
DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
DataGridViewCheckBoxColumn kb = new DataGridViewCheckBoxColumn();
cb = CreateComboBoxColumn("Category", "Category");
kb = CreateCheckBoxColumn("Include", "Include");
dataGridView.Columns.Insert(1, cb);
dataGridView.Columns.Insert(2, kb);
}
// ---------
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
DataRowView testCase = (DataRowView)dataGridView.Rows[0].DataBoundItem;
String fileStream = testCase["Include"] + "," + testCase["Category"];
}
I've been working on it for days but NO LUCK !! Can you please give me a hand?!
Elvia
|
|
|
|
|
Hi, I was wondering how to make the unvisible btnClose visible when btnOpen is Clicked, then hide btnOpen when btnClose is Clicked, so it is kind of like a loop. Feel free to email me
|
|
|
|
|