|
|
Hi
I want to use the Keyeven but It dont fonction.
can anyone help me please.
also i used the button caption, but it dont fonction when i do a evenement .
thanks
void textBoxText_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.ControlKey)
{
this.textBox.Text = "salut";
);
}
else this.textBox.Text = "salut";
if(e.KeyCode == Keys.Delete) this.textBox.Text = "salut";
this.textBox.Text = "con";
}
|
|
|
|
|
Conditions like e.KeyCode == Keys.ControlKey are valid, and they work. The code snippet you have posted is utter crap (does not even compile), but may be it wasn't on purpose.
|
|
|
|
|
Hi!
I have create my own control in C#. When I try to use it on my WIndows Form I get an HRESULT exception and the control is never created. Anyone knows how can I debbug this in order to detect the error???
Thanks in advance!
|
|
|
|
|
Hello,I'm trying to write a class library which can parse several WebPages automatically by mshml. But I'don't know
how to get a free IHTMLDocument2 interface which is not attatched to any control or view.
Using C++,this can be done by call to CoCreateInstance() function:
MSHTML::IHTMLDocument2Ptr pDoc;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,IID_IHTMLDocument2, (void**)&pDoc);
I want to know how to get a free IHTMLDocument2 interface in csharp.
hope I get some replies,
thanks
|
|
|
|
|
It's pretty much unnatural, but here it goes :
using mshtml;
using System.Runtime.InteropServices;
[ ComImport, Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPersistStreamInit
{
IntPtr GetClassID();
void IsDirty();
void Load(IntPtr pStream);
void Save(IntPtr pStream, bool fClearDirty);
long GetSizeMax();
void InitNew();
}
{
mshtml.HTMLDocumentClass doc = new mshtml.HTMLDocumentClass();
IPersistStreamInit pS = (IPersistStreamInit) doc;
pS.InitNew();
doc.createElement("<a href='http://www.codeproject.com'>link</a>");
MessageBox.Show ("nb elements = " + doc.all.length);
...
}
|
|
|
|
|
|
hi,.S.Rod.
I'm extracting all links from a webpage,after I'use
doc.createElement("link");
how I get all links from page "codeproject".
|
|
|
|
|
Semantically a link tag is not an hyperlink tag. An hyperlink tag is known as an anchor. A link tag is what refers to external javascript or css files.
To know which method, collection or member to call, you must first define what you call a link. And then, either you have a collection ready for use (such as doc.anchors for all hyperlinks), or you'll have to parse the entire DOM tree matching tag names.
Good luck!
|
|
|
|
|
Hello,
In my project I have two forms:
frmMainForm (Mdi parent)
frmLogon (dialog)
- components on frmLogon: (edUserName, edPassword, edDatabase) - TextEdit
(btnOk, btnCancel) - Buttons
In frmMainForm Load event i wrote this code;
{
frmLogon Logon = new frmLogon();
Logon.ShowDidalog();
if (Logon.DialogResult == DialogResult.OK)
{
this is my problem, I don't know how can I get values from edUserName, edPassword... to build connectstring.
I mean something like that string username = Logon.edUserName.Text;
}
}
I hope you understand me
Thank you for answers
Anze
/*sorry about my bad English*/
|
|
|
|
|
The best thing to do is to implement your dialog results through properties of the frmLogon, i.e.
In your frmLogon, you begin by declaring some private fields
private string userName;<br />
private string password;<br />
private string databaseName;
Then, you create the properties (also in fmrLogon)
public string UserName<br />
{<br />
get<br />
{<br />
return userName;<br />
}<br />
set<br />
{<br />
userName=value<br />
}<br />
}<br />
<br />
public string Password<br />
{<br />
get<br />
{<br />
return password;<br />
}<br />
set<br />
{<br />
password=value<br />
}<br />
}<br />
<br />
public string DatabaseName<br />
{<br />
get<br />
{<br />
return databaseName;<br />
}<br />
set<br />
{<br />
databaseName=value<br />
}<br />
}
After this, don't forget to update your variables when the user presses the OK button. Something like
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.UserName=textBox1.Text;<br />
this.Password=textBox2.Text;<br />
this.DatabaseName=textBox3.Text;<br />
}
Having done this, you are now able to access your dialog results in the main form through the properties. For example...
frmLogon Logon=new frmLogon;<br />
<br />
if(Logon.ShowDialog()==DialogResult.Ok)<br />
{<br />
<br />
this.myTextBox=Logon.UserName +Logon.Password +Logon.DataBaseName<br />
}
|
|
|
|
|
Hello,
I don't know how add images to main menu or popup menu.
Thank you for answers
Anže
/*Sorry about my English*/
|
|
|
|
|
|
I have a DLL which may be called by more than one exe or more than one instance of an exe. I need the DLL to be able to figure out which exe it is or more precisely, I want it to access some config information regarding the exe.
I am currently trying to fool around with
System.AppDomain.CurrentDomain.SetupInformation (this is in my DLL to get info on the app)
but not sure if that is what I should be doing.
Any clues?
Thanks
|
|
|
|
|
Figured it out. I need to use System.Configuration and create an app config file to do what I need.
|
|
|
|
|
Can anyone tell me the correct code to use to clear the checkmarks (not the items) in a CheckedListBox? I want to do this as sort of a reset function to allow the user to start over making their selections.
Thanks for any help you can give me.
|
|
|
|
|
for( int i=0 ; i < checkedListBox1.Count; i++ ) <br />
{ <br />
checkedListBox1.SetItemChecked(i, false); <br />
}
Earlier I provided the solution for normal Checkbox.
Don't and drive.
|
|
|
|
|
You left out the refences to Items. But it works. Thanks.
It should be:
for (int i = 0 ; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, false);
}
|
|
|
|
|
I am creating a strongly-typed collection class for a custom class using the CollectionBase class. I have added a Sort() function to the class with the following description:
public void Sort()
{
myClass[] tempArray = new myClass[List.Count];
tempArray.Initialize();
List.CopyTo(tempArray, 0);
Array.Sort(tempArray);
List.Clear();
foreach(myClass val in tempArray)
List.Add(val);
} Is there a better way to do this, performance wise? Or is this implementation a decent one?
FYI: The list count for this collection will be very large when used in the application.
Mark Sanders
sanderssolutions.com
|
|
|
|
|
Mark Sanders wrote:
Is there a better way to do this, performance wise? Or is this implementation a decent one?
Maybe there is another way of doing it, but the only one that passes through my mind now is the SortedList container.
Do you really need to have a Sort method or can the list be sorted all the time? If this is the case, then deriving from or aggregating a SortedList can give you the best performance.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
The collection cannot be automatically sorted. In use, the collection will usually be unsorted. Only on occasion will sorting be necessary. Thanks.
Mark Sanders
sanderssolutions.com
|
|
|
|
|
Since you're inheriting from CollectionBase you can use the underlying ArrayList's Sort method. That will (should anyway) in turn call the underlying Array's Sort method.
You can access the ArrayList by the protected InnerList property on the CollectionBase.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
James T. Johnson wrote:
Since you're inheriting from CollectionBase you can use the underlying ArrayList's Sort method. That will (should anyway) in turn call the underlying Array's Sort method.
It actually calls an quicksort implementation. Saw it many moons back. Quite fast as well.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
leppie wrote:
Quite fast as well.
If the data is not already sorted (which is the worst case of the QuickSort algorithm)
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
hi,
i have a databound datagrid control in a winform. i need work arounds for some problems.
1. When i click the last row in the datagrid a new row is automatically added. i need to control this new row addition. Before adding a new row I need to check existing rows in the datagrid and validate against some criteria. Depending on the values existing in the datagrid I want to reject or accept the addition of the row. How can i do this. I tried onRowchanging event of the table the datagrid is bound to but got into some other problems.
2. How can i undo a latest edit made in a databound datagrid again based on some criteria.
3. I have included a combobox inside the datacolum and the combobox again includes a tree view inside. i got most of the job done but whenever i try to add a new row in the datagrid it adds up three new rows. Then when i click on the first of the newly added rows the other two disappear but when i click on the 2nd and 3rd i get the arrayindexoutofbounds exception. Any solutions for this?
hope I get some replies.
Thanks.
|
|
|
|