|
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!
|
|
|
|
|
|
Hi
My MainForm's got 3 panels, top/left and bottom. When I click button on MainForm the LeftPanel gets populated by Form2. When I click a bottun on Form2 I need to add another Form3 to the TopPanel on the MainForm?
Thanks
DM
|
|
|
|
|
Make classes Form2 and Form3 extend UserControl, not Form. Then your click code is simple...
public class MainForm : Form {
private Form2 m_Form2 = new Form2();
...
public MainForm() {
InitializeComponent();
m_Form2.Dock = DockStyle.Fill;
}
...
public Panel TopPanel {
get { return panel_Top; }
}
...
private void btn_AddForm2_Click(object sender, EventArgs e) {
panel_Left.Controls.Clear();
panel_Left.Controls.Add(m_Form2);
}
...
}
public class Form2 : UserControl {
private Form3 m_Form3 = new Form3();
...
public Form2() {
InitializeComponent();
m_Form3.Dock = DockStyle.Fill;
}
...
private void btn_AddForm3_Click(object sender, EventArgs e) {
MainForm parentForm = this.ParentForm as MainForm;
if (parentForm == null) return;
parentForm.TopPanel.Controls.Clear();
parentForm.TopPanel.Controls.Add(m_Form3);
}
}
Hope this helps!
Jeff
|
|
|
|
|
I am attempting to override RichTextBox class and am overloading the appropriate methods to allow drag-drop text. If the source textboxes are NOT readonly, this process works fine. However, when I try to perform a drag-drop from a readonly textbox to a writable textbox, my code fails. I know that it is failing because I am setting the e.Effect value to DragDropEffects.Move, when the only effect that I allow is DragDropEffects.Copy. What I don't understand is how I can, at runtime, determine if DragDropEffects.Move is available as an option. In both my event handlers for DragEnter and DragOver, e.AllowedEffect appears to ALWAYS be (Move | Copy | Select) regardless of what I set it to in the call to DoDragDrop(). I know there is a way to see what options are available, because I can drag from my readonly textboxes into wordpad. I am also wondering why, when I override the ReadOnly property, does the RichTextBox NOT get displayed in the readonly style? It is showing up as a normal textbox, despite it being defined as readonly. Thanks in advance for your help.
-Jeff
-- modified at 17:49 Friday 7th September, 2007
|
|
|
|
|
Skippums wrote: e.AllowedEffect appears to ALWAYS be (Move | Copy | Select) regardless of what I set it to in the call to DoDragDrop(). I know there is a way to see what options are available,
That's because your supposed to be setting the available options, not looking for them. The destination of a drag'n'drop operation dictates what options are available, not the sender.
|
|
|
|
|
OK, so the receiver sets the operation... But why do I send the allowable operations with the call to "DoDragDrop(data, DragDropEffects.Copy)". Isn't the second argument the allowable operations? Is there no way to get at the value set in this manner? Right now, what is happening is that in my target, the operation is being set to DragDropEffects.Move (in the DragEnter event), which results in the graphic being DragDropEffects.None since DragDropEffects.Move | DragDropEffects.Copy == 0. Therefore, my target textbox needs to know that Move is not supported. There has to be some way to do this. Please help! Thanks,
-Jeff
|
|
|
|
|
I have several collections derived from ReadOnlyCollection<t>.
For reasons of time and resource management, I don't want to automatically populate the underlying lists unless the collection or one of its properties/methods is actually accessed by some code.
This I accomplish by replacing each method of the ReadOnlyCollection with a "new" method in the derived class whose code first runs a private "loader" method (which loads the collection items), and then returns the base class' value.
Example:
public class MyCollection : ReadOnlyCollection<thing> {
public MyCollection : base( new List<thing>() ) {
}
public new int Count {
get { Load();
return base.Count; }
private void Load() {
// Go to the data source and populate the collection in here
// if it hasn't already been loaded
}
}
It works fine if I work with the derived class.
The problem is that when I assign the class as a DataSource to a windows form control, it doesn't work correctly. The reason is that the control is working directly with the "IList" properties/methods, and so doesn't use replacement code in the derived class.
The correct technique would be to "override" the properties/methods (instead of "new"), but that doesn't work because the ReadOnlyCollection base class doesn't define them as virtual.
Has anyone else worked around this?
Thanks in advance
Jon
|
|
|
|
|
I have a multilayered DataGrid for users to drill into some data. They see a "+" symbol, a la Excel, to expand the datarow and see the source data (see Windows Forms 2.0 Programming, Sells & Weinhardt, pg 730).
Works fine, but I would like to remove the hyperlink and present the data automagically for them (one click instead of two). Just like OK dialogs to reconfirm what you just told the dang thing to do, it will annoy people.
In other words, just open the child control and show it.
Saludos,
I
|
|
|
|
|
Hello,
I was wondering if any one have tryed to have dynamic totals in a data grid view control, The issue I have is that the data would be constantly chaning, refiltering based on what the user selects, and if you have, could you give me some hints as to how to go about it. My other idea would be to make the totals out side of the data grid view, but I am unsure of getting summed columns, and specific cell values... any help, ideas or suggestions would be great.
J
|
|
|
|
|
You can add a calculated column to the datatable that will reflect changes when user changes some values. Here is a website explaining how to achieve it. It also provides some other useful information you might need.
Column Expressions, DataRelations, and Computations[^]
|
|
|
|
|
|
how do i calculate subitems[4] * subitems[5] + all item in listview
I tryade:
Int value = 0;
foreach (ListViewItem lvi in listView3.Items)
{
int.Parse(lvi.subtitems[4].ToString())*int.Parse(lvi.subtitems[5].ToString())
}
label10.Text = value.ToString();
and i´m so wrong..!
do u have some suggests??
|
|
|
|
|
This will not work definitely as value never changes and it is equal to zero all the time. Also, you are iterating over the items and calculating the same product. Instead you should sum them. You say that you need to calculate subitems[4] * subitems[5] but subitems of which items?
|
|
|
|
|
calculate subitems[4] * subitems[5] + (next subitem[4] * subitem[5]
for each subitems[4]*[5]
like this:
columnheader1,columnheader2,columnheader3,columnheader4,columnheader5,columnheader6,
........................................................................................3,5........... 100
.........................................................................................3,5.......... 100
the awnser should be: 700
tnx
|
|
|
|
|
I think you are attempting to do something like...
int result = 0;
foreach (lvi item in items)
result += item.subitem[4] * item.subitem[5];
is this what you are attempting to do? I am really confused by how you get 700 from that example. Just ignore in your next post the fact that the numbers are subitems, and pretend like they are already integers so your problem becomes a bit more clear to the rest of us.
-Jeff
|
|
|
|
|
subitem[4] is price/sides and subitem[5] are how many sides
I wanna se the earned money..3,5*100 + 3,5*100 = 700
how do i pass the result to a label.text
|
|
|
|
|
andredani wrote: how do i pass the result to a label.text
Make a string out of the result and assign it to the Text property:
label.Text = result.ToString();
---
single minded; short sighted; long gone;
|
|
|
|
|
Skippums has the answer and to put it to a label.
Label1.Text = result.ToString();
|
|
|
|
|
do i miss something..? i don´t get it?
foreach (ListViewItem item in listview3.items)
{
result += item.subitem[4] * item.subitem[5];
}
Label12.Text = result.ToString();
is this right??
|
|
|
|
|
That will iterate through all the ListViewItems in listview3's items collection.
With each item it will multiple the 4th subitem with the 5th subitem and add that to the result variable. Once the loop has completed, you are assigning that result variable to the Text property of the Label control.
So let's assume this ( using periods for decimal <US Standard> ):
listview3 contains:
row1: blah, blah, blah, blah, 3.5, 100
row2: blah, blah, blah, blah, 2.5, 100
result = 0
First Iteration of loop: 3.5 * 100 = 350 : result = result + 350, so result is now 350
Second Iteration of loop: 2.5 * 100 = 250 : result = result + 350, so result is now 600
Hope that helps explain it.
|
|
|
|
|
You excplains pretty nice Chris =)
int result = 0;
foreach (ListViewItem lvi in listView3.Items)
{
result += (lvi.SubItems[4].ToString()) * (lvi.SubItems[5].ToString());
}
label12.Text = result.ToString();
it says: Error1Operator '*' cannot be applied to operands of type 'string' and 'string'
can´t i use * in that order?
What do should i do??
-- modified at 19:56 Friday 7th September, 2007
|
|
|
|
|