|
Cast the item back to whatever it was then access that object's properties.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
can u please give a code example
|
|
|
|
|
using System.Windows.Forms;
public partial class Form1 : Form
{
ListBox listBox1;
public Form1()
{
InitializeComponent();
listBox1 = new ListBox();
Controls.Add(listBox1);
FillList();
MyClass secondItem = (MyClass)listBox1.Items[1];
MessageBox.Show(secondItem.MyStringProperty);
}
void FillList()
{
listBox1.Items.AddRange(new object[]{
new MyClass("A"),
new MyClass("B"),
new MyClass("C"),
});
}
}
public class MyClass
{
public MyClass(string myStringProperty)
{
MyStringProperty = myStringProperty;
}
public string MyStringProperty
{
get;
set;
}
public override string ToString()
{
return MyStringProperty;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
System.Row.DataRowView item = (System.Row.DataRowView)Listbox.items[i];
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi,
if the ListBox shows the item's information, and item.ToString() does not, then
item.GetItemText() is what you want.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I am reading in a WebBrowser.DocumentText with a timer every x seconds.
The content on the website is being updated with AJAX for new ticket information etc.
When I start my app it works fine, it sees there are x new tickets, the timer runs but the DocumentText contains the initially loaded HTML so the timer never sees the new ticket count. Is there a way to reload the DocumentText etc so it updates when AJAX changes values etc.
So basically
start app initial call sees 4 new tickets... fine that is right
submit a ticket web page updates and now says 5....
timer runs around still sees 4 as if the DocumentText never changes with what I see.
Thanks for the help!
|
|
|
|
|
Why don't you directly request for the web page rather than depending on WebBrowser control? WebClient class has got methods to do this.
|
|
|
|
|
Because I also need the web functionality too. Basically I am interfacing with an extiting support ticket system with a C# application so that I do not have to keep my web browser open constantly.
Thanks for you reply.
|
|
|
|
|
Hi
i want to execute some operations(insert into multiple tables) inside a single transaction via TableAdapter class.
i found this article about how to make tableAdapters transactional : http://blah.winsmarts.com/2006/06/18/the-definitive-tableadapters--transactions-blog-post.aspx[^]
but it's good for a single tableAdapter, wheras i want to insert,update to more than one table, hence i must use multiple TableAdapter for each table and i think above link does not good for this operation.
can anybody help me about this issue ?
Note : i don't want to TransactionScope clas, because it has a low speed.
any idea wood be great appreciated.
Thanks
|
|
|
|
|
hdv212 wrote: i don't want to TransactionScope clas, because it has a low speed.
I am hearing that first time. It worked well for my applications. Do you have any benchmark?
You can use normal SqlTransaction[^]. When all tables are updated, commit the transaction, else rollback. You have to use the same connection instance for doing all the table updations.
|
|
|
|
|
Hi N a v a n e e t h
because my above code make our transaction promote to msdtc, the speed almost decrease and make speed lower, however i extended one of my tableAdapters and add two simple methods like this :
namespace TransactionScopeInsertSample.TestDataSetTableAdapters
{
public partial class t5TableAdapter : System.ComponentModel.Component
{
public SqlConnection OpenConnection()
{
if (this._connection == null) this.InitConnection();
if (this._connection.State != System.Data.ConnectionState.Open)
this._connection.Open();
return this._connection;
}
public void CloseConnection()
{
this._connection.Close();
}
}
}
now, i use this code to make my code transactional (without promote to msdtc) :
using (TransactionScope ts = new TransactionScope())
{
try
{
TestDataSetTableAdapters.t5TableAdapter adapterT5 = new TransactionScopeInsertSample.TestDataSetTableAdapters.t5TableAdapter();
TestDataSetTableAdapters.t6TableAdapter adapterT6 = new TransactionScopeInsertSample.TestDataSetTableAdapters.t6TableAdapter();
adapterT6.Connection = adapterT5.Connection;
adapterT5.OpenConnection();
adapterT5.Insert(int.Parse(this.textBox1.Text));
adapterT6.Insert(int.Parse(this.textBox2.Text));
adapterT5.CloseConnection();
ts.Complete();
MessageBox.Show("Values inserted!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
but my question is that, is this best practice ?
|
|
|
|
|
I am not sure. But it looks OK. What happened when you tried?
|
|
|
|
|
Hi again N a v a n e e t h
I tried and get good result, did u try it too ?
|
|
|
|
|
|
Don't crosspost in a bunch of forums. It's considered very rude.
|
|
|
|
|
I could to convert a range object to a string, this way:
string selectedRange = resRange.get_Address(false, false, XlReferenceStyle.xlA1, false, false);
Now, how can I get back the range object from the string('selecteedRange' whose value is say "D10:E20")???
thanks.
|
|
|
|
|
oh, no one responded yet,
anywayz, i got it myself...
here's what i've done:
string []s = selectedRange.Split(new char[]{':'});
Range res = ((Worksheet)MyApplication.ActiveSheet).get_Range(s[0], s[1]);
Regards.
|
|
|
|
|
|
Please read the point 9 here[^]
|
|
|
|
|
If you are using .NET 3.5, you can do
string reversedString = new string(originalString.ToCharArray().Reverse().ToArray()); .
Otherwise, just use a for loop and do it manually.
Edit - this works in .NET 2.0 too:
List<char> charList = new List<char>(originalString);
charList.Reverse();
string reversedString = new string(charList.ToArray());</char></char>
|
|
|
|
|
There is no such interface provided by the string class
we have to do it usind somw work arounds
here is one sulution
1. Convert the string to character array
2. Array provides interface to reverse its element
3. you got ur string in reverse order
|
|
|
|
|
First, put your foot down on the clutch.
Second, put it into reverese gear.
Third, slightly press down on the accelerator and bring the clutch up till it starts to reverse (aplly more accelartion as needed)... easy
...OH, String - sorry i thought you said car... though technically you didnt speak at all... you not still reading are you?... though why am i still talking (i mean writting) complete rubbish?!?!? TGIF
(On a serious note though (as found hidden between D# and E(well perhaps 90% serious :P)) <- i hate it when that happens lol
If you are doing a homework assignment of some sort may i suggest you comment out any code you have taken from the other posts (still keep thou for proof of concept) and write something like as follows - its all about the theory really.
public string MyReverseFunction(string s)
{
string result = "";
for(int i = s.Length-1; i >= 0; i--)
result += s[i];
return result;
}
Oh and make a note that it is prob best to use a StringBuilder to help with performance on large strings
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Hello,
i have a little problem, i have more *.DLL-files, one for my core-functions/classes and one api-dll, where i have my classes and functions, which other developer are able to use, but now i must protect some classes from the eyes of other developers. How can i do that? A protected or private class isn't possible...
Or... how to make, that the other developer only get's a signature of my clases, but not really what's in there, because i don't want, that he can use from my API my core-classes (API.DLL has a reference to CORE.dll)
Thanks
modified on Friday, March 6, 2009 3:55 AM
|
|
|
|
|
softwarejaeger wrote: but now i must protect some classes from the eyes of other developers.
So, you just only want to use the dll yourself, rather than other developer? Can "internal" keyword meet your needs?
I Love KongFu~
|
|
|
|
|