|
Hello All,
I have a user control. which contains a tree view as well as list view control. One at a time will show. I have problem with ListView. I am adding item in at runtime on OnDraw method. I have also override OnMesureItem. Now i want to clear the the item. But there is some problem with it. When i click on submit button, old items should cleared and new ones should be added. But when i click on submit button. The new items added to the list , they are not getting cleared.
I used:-
Item.Clear();
Can anybody help me.
|
|
|
|
|
How do we create events for a user control which is dynamically added?
Thanks in advance
R.K
|
|
|
|
|
In Your control which is too added class;-
Declare delegate:-
public delegate void ShowTextEvent(string str,EventArgs e);
Declare event:-
public void ShowTextEvent MyEvent;
/////////////////////////////////////////////////////////////////////
void somemethod()
{
//////////////////////////////// Control is added
Controls.Add(NewControl);
/////////////////////////////// Setting Event to this.
NewControl.MyEvent+=new ShowTextEvent(OnMyEvent);
}
////Handler
void OnMyEvent(string str,EventArgs e)
{
}
|
|
|
|
|
Hi aslam,
i have a user control created with a button on it.
I am creating an instance of this user control using statments
IComponent newComponent = Activator.CreateInstance(componentClass, objparams) as IComponent;
now i need to add event to this component.
i want the click event of the user control.
please help.
thanks in advance.
|
|
|
|
|
how can i change tags in xml file such as attachment picture with another one automaticly when another attachment arrive to some folder such that i have a attachment picture name rrr.jpg and i want a program to change the name of the attachment when a new picture arrive to a folder and replace it with the new pic that arrive if any as a loop every 30 sec to check if there is a new pic and replace it with the arrived pic and also save the xml file after modification in spicific location and also if the program could replace the old pic with the new one and the program must run always and check for new pic and i hear that this could be done using C# so if any body can help me thatwill be so nice thanks for your time
moadbrkt
|
|
|
|
|
moadbrkt wrote: how can i change tags in xml file such as attachment picture
Use XMLDocument to load your XML String or XML File and then iterate on it and when you reached the desired node use InnexText to set the new text.
moadbrkt wrote: the program must run always and check for new pic
Try using a WindowsService
Do your best to be the best
|
|
|
|
|
no i want to change the tags automticly
|
|
|
|
|
I need to use it to show data for products or shops
As I’m making a e-commerce site
So, I want to know how I use the repeater in a dynamic way
To support the rows that was selected
And to target every column in a label and to put the title beside it
Thanks for help!
Ah_Mohsen
|
|
|
|
|
Wrong forum, it should be in the ASP.NET forum.
But:
in the aspx file:
<br />
...<br />
<asp:Repeater ID="MyRepeater" runat="server"><br />
<ItemTemplate><br />
<br />
<%# ((MyProductClass)DataItem.Container).ProductName %><br />
<br />
</ItemTemplate><br />
</asp:Repeater><br />
<br />
...<br />
in the .cs file
Page_Load()
{
...
List<MyProductClass> products = MyProductClass.GetProductListFromDatabaseOrSomething();
MyRepeater.DataSource = products;
MyRepeater.DataBind();
...
}
it's usual practice to put the above code within a if (!IsPostBack) {... } block so that it only gets loaded on the first page load rather than after every postback.
Hope that helps,
ChrisB
|
|
|
|
|
Sorry, the first block should read:
<br />
...<br />
<asp:Repeater ID="MyRepeater" runat="server"><br />
<ItemTemplate><br />
<br />
<%# ((MyProductClass)DataItem.Container).ProductName %><br />
<br />
</ItemTemplate><br />
</asp:Repeater><br />
<br />
...<br />
|
|
|
|
|
I put this in m code:
public class Row : System.Windows.Forms.ListViewItem<br />
{<br />
public int id;<br />
public int online;<br />
}
And have this code
ListViewItem item = new ListViewItem(new string[] {reader[NAME].ToString(), reader[GAME].ToString(), reader[BNAME].ToString(), reader[BOARD].ToString()});<br />
Row row = (Row)item; <-- ERROR OCCURS HERE<br />
row.id = Convert.ToInt32(reader[ID].ToString());<br />
row.on1ine = Convert.ToInt32(reader[ONLINE].ToString());<br />
MainForm.listView1.Items.Add(row);
But i get the above error, that it couldn't cast ListViewItem as Row. Ive done this before with TreeNode and it all worked fine, what wrong with this one?
Why did my row.online get replaced with row.removed, it doesn't do it outside the code brackets?
-- modified at 20:31 Tuesday 10th October, 2006
|
|
|
|
|
I'm now just storing row in item.Tag, and it works (of course) but i still want to know why this won't work, i just can't see it.
|
|
|
|
|
Because ListViewItem and Row are different classes and don't have
1. an is-a relationship
2. implicit conversion operators.
It obviously won't work with TreeNode also,as that class is not related in any way to the Row class that you wrote. You probably would have used the Tag property, just like you did now.
|
|
|
|
|
Actually i didn't use the tag.
Whith the tree node i had:
public class Cheat : Windows.Forms.TreeNode
{
public string code;
public string gameid;
lots of other public strings
}
My class inherited from the TreeNode.
So i had
Cheat oNode = new Cheat();
oNode.code = stuff
oNode.gameid = stuff
this.treeview1.nodes.Add(oNode);
and i could go:
foreach(Cheat oNode in treeview1.selectednodes)
and
TreeNode main = new TreeNode();
Cheat gNode = (Cheat) main;
or
Cheat gNode = new Cheat();
TreeNode main = (TreeNode)gNode;
Oh, and yes, when getting the nodes back from the list they still had all the values that where stored in my custom things by just going
Cheat check = (Cheat)this.treeView1.SelectedNode;
MessageBox.Show("The code in the node is... " + check.code);
-- modified at 23:37 Tuesday 10th October, 2006
|
|
|
|
|
That code works because your Cheat class inherited from the TreeNode, which is exactly what you were casting it to and from. A TreeNode has no relation to a Row
- Aaron
|
|
|
|
|
This works as you create a Cheat object, store its reference using a variable of its base class (TreeNode ) and cast back later. Hereby the real object on the heap stays the same (Cheat object) all time long.
The Row example doesn't work as you create an object of the base class (ListViewItem ) and afterwards try casting to a sub class. This simply can't be done as the object on the heap is now Row .
"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
|
|
|
|
|
If possible could anyone please suggest how to do Forcolor change in disabled mode (Black color) for Drop downn or combo box.
I got color change fine but i am having problem in binding all the items.I cannot see items after color change ,i just see something like System.Data.Datarow in the place of items in combobox.
I am using Window forms with C# (ASP.NET 1.1 framework) ,visual studio 2003.
Thanks
OR
Suggest some other way to do the forecolor change in disable mode for combobox.
|
|
|
|
|
What do you mean by disabled mode? I don't quite get it.
|
|
|
|
|
Hi ,
Disabled mode means when we set Enable property to false.Than it does not allow use to handle the control.Disable means you cannot edit,or nothing you can do.
Is this clarify your doubt?
|
|
|
|
|
Yeah i thought that what you meant, but i can't seem to be able to change any colours when its disabled.
|
|
|
|
|
Hi again,
Yes you can change the forecolor.Just go through this example :
http://www.codeproject.com/cs/miscctrl/disabledcombodisplay.asp
But for me the forecolor is changing but it is giving problem in displaying all the items of the combobox.It just displays one and it gets repeated several times.Just check the code of the above example.
May be you can suggest some more ideas.
Thanks
|
|
|
|
|
error CS1577: Assembly generation failed -- Referenced assembly 'NCI.EasyObjects' does not have a strong name
error CS1577: Assembly generation failed -- Referenced assembly 'Microsoft.Practices.EnterpriseLibrary.Data' does not have a strong name
I am referancing these DLLs inside my COM dll.
|
|
|
|
|
kolu narayan wrote: CS1577
See if this KB article[^] helps.
led mike
|
|
|
|
|
Thanks for your reply.
This is what happening, i had tried your suggestion as well. but unfortunately things didnt well.
I have a COM dll in C# which i had named 'MyWrapper.dll'. Now in this dll i am referencing other 3rd party dll's which are
'NCI.EasyObjects.dll' and
'Microsoft.Practices.EnterpriseLibrary.Data.dll'. Now when i tried to strong name my MyWrapper.dll it gives the following error.
error CS1577: Assembly generation failed -- Referenced assembly 'NCI.EasyObjects' does not have a strong name
error CS1577: Assembly generation failed -- Referenced assembly 'Microsoft.Practices.EnterpriseLibrary.Data' does not have a strong name
Now like what you said i had tried
C:\MyWrapper\bin\Debug>dir
10/10/2006 02:09 PM 20,480 DbConnection.dll
10/11/2006 09:27 AM 16,384 DTS_Access.dll
10/11/2006 09:27 AM 15,872 DTS_Access.pdb
12/17/2002 06:23 PM 131,072 Interop.DTS.dll
09/15/2006 02:07 PM 57,344 Microsoft.Practices.EnterpriseLibrary.Com
mon.dll
09/15/2006 02:07 PM 118,784 Microsoft.Practices.EnterpriseLibrary.Con
figuration.dll
09/15/2006 02:07 PM 86,016 Microsoft.Practices.EnterpriseLibrary.Dat
a.dll
10/11/2006 09:35 AM 596 MyKeyPair.snk
03/12/2006 03:45 PM 73,728 NCI.EasyObjects.dll
11/29/2005 12:44 AM 145,755 NCI.EasyObjects.xml
C:\MyWrapper\bin\Debug>tlbimp NCI.EasyObjects.dll /delaysign /publi
ckey:MyKeyPair.snk /out:Interop.NCI.EasyObjects.dllMicrosoft (R) .NET Framework Type Library to Assembly Converter 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
TlbImp error: The input file 'C:\MyWrapper\bin\Debug\NCI.EasyObject
s.dll' is not a valid type library
C:\MyWrapper\bin\Debug>tlbimp Microsoft.Practices.EnterpriseLibrary
.Data.dll /delaysign /publickey:MyKeyPair.snk /out:Interop.Microsoft.Practices.
EnterpriseLibrary.Data.dllMicrosoft (R) .NET Framework Type Library to Assembly Converter 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
TlbImp error: The input file 'C:\MyWrapper\bin\Debug\Microsoft.Prac
tices.EnterpriseLibrary.Data.dll' is not a valid type library
Bascilly why am i getting "is not a valid type library" error. Please help. How would i be able to strong name those dll's which are 3rd party.
|
|
|
|
|
Ok I found it, basically i went to the source code for each dll i was refering and then strong named it myself and compiled. Now the pain is any other dll referenced by those dlls also have to be strong named.....
But finally got the result.
thanks...
|
|
|
|