|
have search in internet the hole day after this.. can you help me....
|
|
|
|
|
Did you read my post? If there is something that you don't understand, say what it is instead of just pretending that I didn't write it.
---
single minded; short sighted; long gone;
|
|
|
|
|
no.. i meant that i haved googled on text property and listview property..
But i did´t find the awnser..
I have come as far as this:
if (listView2.SelectedItems.Count > 0)
{
int number = 0;
foreach (ListViewItem lvi in listView2.Items)
{
bool alreadyExists = true;
while (alreadyExists)
{
alreadyExists = false;
foreach (int existingNumber in lvi.SubItems[1].Text)
{
if (existingNumber == number)
{
alreadyExists = true;
break;
}
}
if (alreadyExists)
{
number = number + 1;
}
}
this.listView2.Items.Add(number.ToString());
}
}
changed a little bit but (i only get 0 in my listview, its beacause int number = 0;)
-- modified at 19:01 Saturday 8th September, 2007
|
|
|
|
|
I don't understand what nodes you want duplicated, you might need to post an example of the input and output. There is not much point in doing a foreach over a single item like you have done in the inner loop.
Here is an example that duplicates each node in the listview and increments the subitem. This only adjusts SubItems[1] other subitems are not changed. It also does no checking if SubItems[1].Text is an number or not.
e.g
Before:
A 1
B 1
C 1
After:
A 1
B 1
C 1
A 2
B 2
C 2
foreach (ListViewItem item in listView1.Items)
{
int value = int.Parse(item.SubItems[1].Text);
ListViewItem newItem = (ListViewItem)item.Clone();
newItem.SubItems[1].Text = (value + 1).ToString();
listView1.Items.Add(newItem);
}
|
|
|
|
|
it´s gonna work like this:
before:
a k111
b k111
a k112
after a click on a k111:
a k111
b k111
a k112
a k113 (this is the copy)
|
|
|
|
|
What are you trying to do really? The text of a SubItem is a string, and a string doesn't contain any integers, it only contains characters.
If you use foreach on a string, it will loop through the characters in the string, and casting each character to int means that you get the unicode character codes for the characters in the string. You won't find any characters in the string with the character code 0.
What does the SubItems contain? If it is the string representation of a number, you have to parse the string if you want to get the number. Use the int.Parse method.
---
single minded; short sighted; long gone;
|
|
|
|
|
Subitem[1] is gonna contain one letter and than all numbers, like this:
Before:
A k111
B k111
A k112
After a click on A k111:
A k111
B k111
A k112
A k113
|
|
|
|
|
andredani wrote: Subitem[1] is gonna contain one letter and than all numbers, like this:
Before:
A k111
B k111
A k112
After a click on A k111:
A k111
B k111
A k112
A k113
That doesn't make sense.
"A k111" is not one letter then all numbers. That's a letter, a space, another letter, and then some digits.
If you click "A k111", what is the process to get to "A k113"? That's not adding one, so the items have to be related somehow?
---
single minded; short sighted; long gone;
|
|
|
|
|
IList<string> m_SubItems = new List<string>();
if (m_ListView.SelectedItems.Count > 0) {
// Why do you need SelectedItems.Count > 0? ...
// You don't ever reference them again within the if statement
for (int i = m_ListView.Items.Count - 1; i >= 0; --i) {
ListViewItem current = m_ListView.Items[i];
string item = current.SubItems[1].Text;
if (m_SubItems.Contains(item)) {
// This code assumes that all integers have only one digit.
// If you want something different, you must change how index is created.
int index = (int)item[item.Length - 1];
item = item.Substring(0, item.Length - 1);
do {
ListViewItem newItem = new ListViewItem();
...
newItem.SubItems.Add(new ListViewSubitem(item + (++index).ToString()));
m_ListView.Items.Add(newItem);
} while (m_SubItems.Contains(item + index.ToString()));
} else {
m_SubItems.Add(item);
}
}
}
Hope this helps!
Jeff
|
|
|
|
|
thanks man!
but this says:
newItem.SubItems.Add(new ListViewSubitem(item + (++index).ToString()));
Error 1 The type or namespace name 'ListViewSubItem' could not be found
tnx
|
|
|
|
|
I never type in a compiler. Push F1 when the cursor is over Add, and see what type it should be
|
|
|
|
|
it does´t work for me, i´m i doing wrong??
i get all the listview items subitem[1] copyied and the rest empty... strange...
|
|
|
|
|
|
IList<string> m_SubItems = new List<string>();
for (int i = listView1.Items.Count - 1; i >= 0; --i)
{
ListViewItem current = listView1.Items[i];
string item = current.SubItems[1].Text;
if (m_SubItems.Contains(item))
{
int index = (int)item[item.Length - 1];
item = item.Substring(0, item.Length - 1);
do
{
ListViewItem newItem = new ListViewItem();
newItem.SubItems.Add(item + (++index).ToString());
listView1.Items.Add(newItem);
}
while (m_SubItems.Contains(item + index.ToString()));
}
else
{
m_SubItems.Add(item);
}
}
}
|
|
|
|
|
you need to copy all subitems, not just the first.
|
|
|
|
|
hi all,
I am using a datagridview to display data. In one of the columns i am displaying the title and when i click the title, the row height is adjusted to include title as well as description. i have managed to do this.
Now when i click another row, in the previous row, only the title should be displayed and the description should be hidden.
i did this using the rowleave event of datagridview. but i am not sure whether i managed it right. because i need to click another row twice to get the title and description.
Hope i am clear in my description.
How can i handle this?
Any suggestions please.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
Hi All,
I am working on a C# windows application which uses a MySql db as back-end. it is a huge solution with 100 forms. Everything was fine until last week When I was told, " there is a chance this application will be used my multiple users and same forms can be opened simultaneously(from different machines)". so My application was not designed in such a manner that it can handle multiple user access same data and modify it at the same time. For ex: if one user creates/edits/deletes a record then the other user can not know that a record is created/edited/deleted on the same form.
I thought of using remoting. A windows service on the DB server will have the "users + forms opened" list. As the user logs in and tries to open a form, my application will connect to service and check for, if that form is already opened by some one else. if true, then it will open form in a lock mode. But the problem is, if some one opens the form in lock mode and then the form should be notified once it is unlocked. How should i implement this? I read few articles on Remoting and invoking events but everybody says that it is not a suitable way. What can be other ways please suggest ?
Added to this now i came to know that the application will be run on a terminal server . I tested it on terminal server to see if there are any issue, I found, when my application if run by multiple users can't write to the config file. Only the user who installed it can write into the config file. I thought it is a permission issue which can be resolved. Then i read few posts stating .Net application performance degrades when run on a terminal server. in the sense that Memory consumption is too high. Well i have not tested it for sure. but Will there be any problem with the Remotng part if both the service and my application run on the same terminal server ? Will there be any performance issue ? I am worried because my application is already using 100 mb of memory.
I have very little time left please help
Thanks
KSS
|
|
|
|
|
fearless stallion wrote: I thought of using remoting. A windows service on the DB server will have the "users + forms opened" list. As the user logs in and tries to open a form, my application will connect to service and check for, if that form is already opened by some one else. if true, then it will open form in a lock mode. But the problem is, if some one opens the form in lock mode and then the form should be notified once it is unlocked. How should i implement this? I read few articles on Remoting and invoking events but everybody says that it is not a suitable way. What can be other ways please suggest ?
Your problem isn't going to be handled by "locking forms". That just complicates things beyond what is necessary. This issue is data concurrency. As your application stands now, every user can open look at anyn data they want and modify it, all at the same time. The problem comes when the users start writing that data back to the database. Right now, your app can only do "last write wins". The last write back to the database overwrite any changes made by anyone else. It someone else is looking at the same data, they will NOT get notified of the change.
This is normally solved by adding a timestamp field to each table in the database that's shared by multiple users. In the SQL code that writes the changes back to the database, each row's primary key is used in the SQL's WHERE clause to locate the record to update, but you also include the date/time that was read from the database in the WHERE clause. If the date/time is different than the one you got, the record will not be found, meaning someone else has updated the database while you were looking at the data. What you do in that situation is up to you.
Try reading this[^] and this[^] and this[^] and a few articles from this list[^].
Basically, you've got a HUGE problem to fix, but no time to do it. I think it's time to tell management to face reality, because you're going to need more time to redesign your applications data layer. I'd tell them after you read this stuff and show them a plan of attack on the problem, 'cause there is no "quick fix" for this.
|
|
|
|
|
Dave Kreskowiak wrote: Basically, you've got a HUGE problem to fix, but no time to do it. I think it's time to tell management to face reality, because you're going to need more time to redesign your applications data layer. I'd tell them after you read this stuff and show them a plan of attack on the problem, 'cause there is no "quick fix" for this.
Thank you very much Dave.
Yes there is no immediate solution to this problem. and i will go through the links. i will let you know once i am done with the links
thanks again
KSS
|
|
|
|
|
I have a single line TextBox in one TabPage in a TabControl.
The TabControl SelectedIndexChanged event handler looks like
<br />
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
if (tabControl1.SelectedIndex == 0)<br />
this.textBox1.Focus();<br />
}<br />
When I toggle through the tab pages via Control-Tab everything looks good.
When I toggle backwards through the tab pages via Control-Shift-Tab the text
alignment of the text box somehow gets set to right, even though when I step
through the debugger the TextAlign property is set to HorizontalAlignment.Left
Any ideas?
|
|
|
|
|
Hi Friend
u can do only one thing . you have written tabcontrol1_selectedindexchanged instead you write tabcontrol1_click event . then curli braces u write this.textbox1.focus
your problem is solve
have a good day
|
|
|
|
|
Yes but then the focus will not get set to the text box, if the user uses Control-Tab to scroll through the tab pages.
|
|
|
|
|
Part 1
I have a component (myComponent) which has a designer class (myComponentDesigner). The only thing the designer does is to override PostFilterProperties to create the attributes of the component's properties.
When a MyComponent object is dropped into the component tray the attributes (Category, Description, ParenthesizePropertyName(sic), TypeConverter etc) are all apparent in the PropertyGrid; fantastic I can get the attributes out of the code!
However, if I have a collection of myComponents which uses a CollectionEditor then the PropertyGrid in the CollectionEditor.CollectionForm ignores the attributes created by myComponentDesigner. Hence all properties are shown in the PropertyGrid as being miscellaneous, all public properties are shown (the designer applies BrowsableAttribute(false) to many properties), all properties are sans description etc etc.
Is this a feature, undesirable though it may be, is it a defect, or as is so often the case, am I doing something wrong by commission or omission.
Before anyone asks, my code unconditionally invokes base.PostFilterProperties after it has added the attributes - evidence of this is that it works when myComponent's are in the tray.
Part 2
I have a Control derived class called Matrix, that is adorned with several Verbs via its designer class, MatrixDesigner. The verbs appear under the glyph and at the bottom of Matrix's property grid as one would expect.
Amongst Matrix's properties are 5 collection objects - List<Layer> and List<Vector> being two examples, each collection has its own CollectionEditor derived Editor. Within the collection editors the CollectionForm.Controls property is scanned to find the PropertyGrid, if it's found (which it always is), its HelpVisible and CommandsVisibleIfAvailable properties are set to true.
The help area in the CollectionForm PropertyGrid shows what one would expect - the values of the property Description attributes of the Collection subjects (e.g. descriptions of the Layer & Vector properties).
However the Commands area shows the Verbs applied to the the Matrix, which are inappropriate, irrelevant & immaterial in the context of a Layer or Vector. If I apply a designer to the Layer or Vector, it's not processed by the IDE - see Part 1.
Also the collected classes (i.e Layer, Vector etc)have a PropertyTab attribute applied to the class definition thus:-
[PropertyTab(typeof(EventsTab), PropertyTabScope.Component)]<br />
class Vector : Component{<br />
.<br />
.<br />
}<br />
The Events Tab(button) shows up erratically, the only nearly sure way of getting it to "stick around" is to add an item to the collection and then remove it. When it is there it shows the appropriate events (e.g Vector.Grow, Layer.Stretch etc), but the generated code is wrong. The event delegates are assigned correctly in the Form1.Designer.cs :-
this.layer2.Stretch += new LayerEventHandler(this.layer2_stretch);
But, the generated code in Form1.cs looks like :-
private void layer2_Stretch(object sender)<br />
{<br />
}<br />
As you can see there's no "LayerEventArgs e" parameter as one would expect. The IDE "knows" it's failed to do the right thing, because it shows an obscure message, the IDE usually crashes a short time later.
I appreciate scanning CollectionForms.Controls to find a PropertyGrid object is "dodgy", but ...
I also find the various buttons and hide them - eg hide the Add and Remove buttons when I need to present a "fixed collection of objects" which can be individually edited but not created or destroyed.
Rgds PhilD
-- modified at 23:48 Friday 7th September, 2007
|
|
|
|
|
I'm building my own remoting structure (for some handheld apps) since MS left remoting out of CF. Right now I'm just testing everything on my desktop. I've noticed a performance issue though.
I'm using HttpWebRequest at the client, I serialize my request into binary form, and post it to an aspx page that handles the request (eventually to be an httphandler). The response is binary that I parse back on the client.
I'm now just doing some basic performance testing. When I run the client,aspnet page in IIS, and database (SQL 2005) on the same machine, I can upload and save 1000 records in 10 seconds (1000 SEPARATE http requests). If I point the connection string in the aspnet aspx to a a different database on another machine, I still get roughly the same 10 second performance. HOWEVER, if I put my client on another machine, and point it at a machine with the aspnet aspx page AND database, performace drops tremendously. Like 10x slower.
I know the network traffic between client<->aspx and aspx<->database is not the same type of traffic but it seems like the database connection is efficient across machines but NOT the client->aspx. All I can think of is that something about running the client and aspx on the same machine is allowing it to reuse connections but then when I run the client from the other machine, the client HttpWebRequest is no longer reusing connections.
I've set it to use keep-alive but it seems like I have to accept on faith that it will be efficient and reuse the connections.
Any ideas?
Thanks!
|
|
|
|
|
|