|
sender is of type object , which doesn't have a SelectAll() method in its interface. You should cast sender to an object variable of type TextBox in order to invoke properties/methods particular to this class.
TextBox tb = (TextBox)sender;
tb.SelectAll();
Paul Marfleet
|
|
|
|
|
Thanks.
That is alomost exactly what I ended comming up with not too long after posting the message. It seemed a bit round about and redundant, so i was not sure about it.
Would it be correct to assume that since the tb.SelectAll works (selects the text in the original control) means that the tb is a pointer to the actual text box and not a copy of it?
It would seem that you should be able to do it more directly, like (TextBox)sender.SelectAll(); or something similar.
David Wilkes
|
|
|
|
|
amatbrewer wrote: Would it be correct to assume that since the tb.SelectAll works (selects the text in the original control) means that the tb is a pointer to the actual text box and not a copy of it?
Yes.
amatbrewer wrote: It would seem that you should be able to do it more directly, like (TextBox)sender.SelectAll(); or something similar.
Try this one: ((TextBox) sender).SelectAll();
"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
|
|
|
|
|
It would be safer not to assume that the sender is a TextBox (one day it won't be). Code like this:
TextBox tb = sender as TextBox;
if (tb != null)
{
tb.SelectAll();
}
else
{
}
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
hy everyone!
i do already have an idea for this but i thought, maybe there is a better solution than mine (easier, more stable etc.) so that's why i ask:
i do have datafields with one line containing the fielddescription and the second line containing the values. now i do want to store these info so i am able to use it later on.
my idea would be to store it in arrays, one for every dataset. one array field is the fielddescription (FD) and the second one is the value to this description field (VF).
so it would look like this
---------------------------
| 1 | 2 | ....
.....................
|FD1 |VF1 |FD1 |VF1 |
.....................
|FD2 |VF2 |FD2 |VF2 |
.....................
|... |... ||... |... |
......................
|FDn |VFn ||FDn |VFn |
......................
i chose this way because i do want to allow reordering of the "fields" (e.g. datafield11 and datafield22 change places) or there is a new field append to the old ones (lets say a n+1 field).
what way would you define this structure (i would define a two dimensional array, where the second array contains another two dimensional array)?
or do you have a better idea of how to store this info in a datastructure?
the infos in my txtfile i do parse look like this (this are two pairs of info!)
name1, name2, name3, name4, ...
value1, value2, valure3, value4, ...
name1, name2, name3, name4, ...
value1, value2, valure3, value4, ...
where the first pair is the first element in my arraystructure, the second one is the second arrayelement etc.
i do know how many lines they are. because of the structure i am able to count how many pairs are available. so i know the dimension of the datastructure which i do have to provide (with dynamic arrays this is quit easy to do).
but from my point of view my structure looks a little strange, because if you want to access the first value of the first element then you have to do the following
access the first dataelement in the array and then enter the second array to get the required data.
eg.
datalement[1,[2]]
(not correct coded i guess, but you might get the meaning of it.
so my question is: how would you define a datastructure to store the info
name1, name2, name3, name4, ...<br />
value 1, value 2, valure3, value4, ...<br />
name 1, name2, name3, name4, ...<br />
value 1, value2, valure3, value4, ...<br />
....<br />
name1, name2, name3, name4, ...<br />
value1, value2, valure3, value4, ...<br />
name1, name2, name3, name4, ...<br />
value1, value2, valure3, value4, ...<br />
so any idea how to store this info in a more simpley way is welcome.
thanks!
stephan.
|
|
|
|
|
i found a better or easier solution to my problem.
i do not use array in array anymore i decided to use an extra array to store the infos where the data is located in. so my new structure looks like that
<br />
string[,] indexinfo;<br />
string[,] data;<br />
so in indexinfo the first arrayfield gets the fieldname and the second one gets the index.
in data i do store the data, field on is the dataindex (meaning which line) and the second index is the value.
so the indexinfo looks like this
fieldname1 10
fieldname2 13
and the data looks like that
10 20
11 21
12 22
13 23
(each row is a dataline)
that's a lot easier.
but well i have to use two fields to get the info.
stephan.
|
|
|
|
|
Hello,
The problem is .. I want to see my application window sticks on to the desktop (i.e it should never minimize)always like a gadget (but its not a gadget) .It should ignore Lwin+D . And toggledesktop command also (I mean it should not minimize even though we click on showdesktop.scf file).Please help me, that is heart of my academic project.I'm using c#.net 2005.
Example for my requirement is Yahoo gadget .In that we can set the property of the gadget as below so that it will never minimize.
(THANKS IN ADVANCE)
Mahi
|
|
|
|
|
I don't think you can "stop" the show desktop (Win+D) from hiding your application. Even items that cannot be minimized (e.g. applications with a modal dialog open) are hidden.
But I think what you looking for is an Application Desktop Toolbars[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Sorry, Actually Im looking for the gadget kind of thing which stays always on desktop.I have seen that application desktop toolbar .But it is visible always when we are on some other application also.
I have seen yahoo gadget and installed gadget engine to see what is the property that makes the window to stay always below some other applications and sticks to desktop that is
these are the properties values of window level of widget .
konspose, desktop, below, normal, topmost, or floating.
I want to implement one of the value that is below .
Thank you.
Mahi
|
|
|
|
|
Are you talking about This.Topmost ?
|
|
|
|
|
No.If I keep that it always shows my application only.My requirement is it should be on desktop just like wallpaper .whenever we see wallpaper we should able to see our application.
Thank you.
Mahi
|
|
|
|
|
Wow, Lwin+D powerfull stuff. I have stopped all forms of minimizing / maximizing, but Lwin+D still gets the app out of the way.
And as for keeping it at the back... i'm not sure. Then again, you might be able to do something in WndProc to stop your window coming forward.
-- modified at 21:06 Tuesday 30th October, 2007
From what i can tell, an application gets no message when a user presses win+d. It just gets minimized.
From what i can tell of other things, the OS hides all windows, and draws the desktop over everything, and sets some active window property, or somthing similar to null. As a test for yourself, find a window you cannot minimize (try opening up the options for your browser). Do Lwin+D, now, restore or maximize any window other than your browser. As you can see, your browser is restored, though it will have received no message to maximize or restore.
And thats enough of my ramblings. I'm sure they're quite wrong, but who knows...
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
hi everyone!
i used a stream to read a whole txt file into a string variable. this is a copy of a template where tokens have to be replaced by values.
but because i do not know how many pages there will be i have to get it "dynamic" meaning i have to store the page template in a string variable and then copy it once, twice, ... to another one.
the first copy is already there. but because i do not want to loose the original copy i do copy it to another string variable. thats a simple assignment, that's easy. but now i wonder if i do just have to do the following
<br />
string template;
string output = "";
<br />
output = template;<br />
<br />
output = output + template;<br />
but i am not sure if it is formated correctly or if there could be problems when doing the assignment in the last line.
when the info in the textfile looks like this
line 1
line 2
.....
line n-1
line n
then i want it to look like this after having added a second copy
line 1
line 2
.....
line n-1
line n
line 1
line 2
.....
line n-1
line n
but not
line 1
line 2
.....
line n-1
line n line 1
line 2
.....
line n-1
line n
for example. the second "page" should be append to the first one stored in the string variable. and a thrird or fourth copy etc.
but what i do once could be done n times, thats not the problem.
so to sumarize: my question is how do i have to add the streamed info for the second, thrid .... time to an existing and allready filled string without loosing the format during copying?
is there some kind of
string1.append(string2) or anything similar?
thanks.
stephan.
|
|
|
|
|
There should already be a line terminator at the end of each line. You just need to ensure that you append the text for the second file after the final line terminator in the text from the first file.
You can call Environment.NewLine to get the string representation of a newline construct for the current platform.
If you are working with large strings, you should consider using an instance of the System.Text.StringBuilder class. Strings in .NET are immutable, which means that the contents of a string once created cannot be altered. If 2 strings are concatenated, a new string object must be created to store the resulting data. The StringBuilder class provides a more memory-efficient way of manipulating string data.
Paul Marfleet
|
|
|
|
|
How would I edit the items in a tree view when i hit a button.
I'd have a list of codes in 5 different languages, but when i click C# button it'll switch all codes to C#, or C++ button change all text to C++ codes..
Thats not what i'm using it for though, just to change the items in it.
How would I be able to do that, from 2 different windows*
|
|
|
|
|
From the root node, write code to recursively traverse all child nodes in the tree.
For each node, alter the Text property appropriately.
Paul Marfleet
|
|
|
|
|
No, sorry let me make myself clearer
I want 1 Tree view, but i want 50 different text combinations.
I want to click a button and it will switch all the text and nodes.
Like making a form on different sallery's
Do you understand now?
|
|
|
|
|
C# Beginner Nick wrote: Like making a form on different sallery's
I don't understand what this sentence means.
Anyway, do you mean that the tree structure (nodes and text) will be different for each language? You could achieve this by storing a serialized representation of each tree structure in a series of XML files. The tree could then be populated by reading the tree definition from the appropriate file depending on which language the user has selected.
Paul Marfleet
|
|
|
|
|
Alright, i'll just say what i want it to do. Instead of an example
This right here.[^]
Then when i click on Choose game, it brings up a menu asking which console.
I click the console, choose the game, then i want it to change the information in the Tree View to that Gamed information.
Did i make that any clearer?
http://i84.photobucket.com/albums/k40/njk003/This-1.jpg
|
|
|
|
|
The image didn't really help. And, in your original post, you were talking about programming languages. Now you're talking about games. I'm having some difficulty following your train of thought...
However, as I understand it, the tree content should change for each different game that can be selected. You therefore need to persist the tree definition for each game somewhere so that it can be loaded dynamically depending on the user's selection. You could use XML files as I had previously suggested, or you could store the XML in a database. You then would need to write a routine to traverse an XML document and dynamically populate the treeview with nodes that follow the same structure.
Paul Marfleet
|
|
|
|
|
Alright thank you, and at first i was just giving an example for you to follow. Didn't tell you what i was really trying to make. Sorry for the confusion.
|
|
|
|
|
Would it be better for me to change the Tree View to a Text Box, and have the text change when i click the button.
System.windows.form1.Textbox("Text"); ?
|
|
|
|
|
If you just need to display a different paragraph of text depending on the game selected, a TextBox would be sufficient. A TreeView control would be inappropriate and unnecessary. As your previous posts specifically talked about populating a TreeView control, I had made the (reasonable) assumption that you were dealing with some sort of hierarchical data structure. However your requirements are actually less complicated than that!
Paul Marfleet
|
|
|
|
|
I have as a ListBox item a reference to a ScrollingLine class, in which I override ToString() to return the part of text currently visible in a scrolling window. How do I get my ListBox to update its display of that string? Does it make a copy of the ToString() result of each item when initialising, or does it just not know to update and maybe I could invalidate it?
|
|
|
|
|
Hi Brady,
AFAIK a ListBox does not copy data to some internal location, it holds a collection of items,
and works from there.
If you create a reason for repainting it, you should call Invalidate() on the listbox;
you can use optional arguments to restrict the repainted area, but there is no "index"
input available.
You could try and use ListBox.GetItemRectangle to feed ListBox.Invalidate().
Alternatively (I have not tried this!), you could cause a specific item to be repainted
by changing one of its properties, Selected comes to mind. So you could try:
myListBox.SetSelected(!myListBox.GetSelected(index));
myListBox.SetSelected(!myListBox.GetSelected(index));
which toggles the item's selection back and forth, causing two repaints of that one item.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|