|
Hi all,
I've five tabs on a tab page and each contain list view. Views are populated with some data on a click event.
Once I click on a tab, it take bit of time to visible, at that time I can see the tab which is previously selected. So what I've done is refresh the tab when the tab selected index is change.
private void AllTabs_SelectedIndexChanged(object sender, EventArgs e)
{
AllTabs.SelectedTab.Refresh();
}
But still it's not work. Any comments?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
CodingLover wrote: I've five tabs on a tab page
this is not clear.
Do you mean "I have 5 tab pages on a TabControl" ?
CodingLover wrote: I can see the tab which is previously selected
this is not clear.
Do you mean "the previous tab remains visible for some time, only then the newly selected tag appears" ?
If so, your loading of the ListViews (or whatever gets loaded on SelectedIndexChanged() is too slow.
Refreshing all TabPages sure won't help, it is wasting CPU cycles on TabPages that are not visible!
Please clarify the situation, and use correct terms.
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
modified on Sunday, June 12, 2011 8:08 AM
|
|
|
|
|
Sorry for the unclear description here.
Yes, I've 5 tab pages on a Tab Control.
Say I'm focusing on the first tab page. Once click on the second tab page, the first one is visible for a time and then suddenly appear the second one.
More important thing here is, this is happen only on the first time. When I click on any tabs after after this, works fine.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
not sure what you are showing on the tab pages, seems like the first access is slow.
Maybe you are listing filenames by scanning a disk, file caching would make that work faster the next time around.
Or you are accessing a database that hasn't been opened yet, so a first connection needs to be made,
and lots of code need to be jitted.
Whatever it is you need to do to load the pages, try doing it in the background *before* you select
a tab page, so the data (or at least the DB engine, file cache, whatever) gets warmed up.
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
modified on Sunday, June 12, 2011 8:08 AM
|
|
|
|
|
Actually I read a text file and collect some data(read line by line to collect data) and added then in different list views in different tab pages. Actually each tab page have at least one list view.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
reading and parsing a text file should be a matter of milliseconds, not seconds, unless it is huge or a remote file on a slow network. XML is not particularly fast, and offers many ways to make it even slower.
I suggest you measure the time (with a StopWatch) it takes to obtain the data, to parse the data,
and to put it in the Control(s) assuming these are separate actions; with those numbers you can see which part is slow.
Alternatively measure the time it takes for the first data item, and for all N data items; if all is much faster than N times the first, you have heavy initial costs somewhere.
You could consider showing some relevant code, maybe someone will spot a problem at once...
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
modified on Sunday, June 12, 2011 8:08 AM
|
|
|
|
|
Yes, I'm working on text files I can read up to 10MB file less than 10 seconds. I hope it's fine.
Each time I do this, clear all components, like list views and few text boxes. It's working fine extremely well. But unfortunate two things bugging on me.
First one is that tab select issue.
Seconds one is, as I said data adding start on a button click, and clear all components before adding again. In default first tab is selected and to populate all elements take less than 10 seconds.
Now say after first adding I select the second tab. And start adding data using the click event. This time it take around 20 seconds to adding data.
Can you make ma suggestion for me.
BTW: I've already use that SuspendLayout ResumeLayout in adding.
Thanks for the commenting here sir.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
now you mention textboxes. They are known to be slow, loading them is a quadratic job. How much data should they hold?
Reading 10MB of text files in 10 seconds is rather slow assuming a modern PC. What is the data, how difficult is the parsing, show a couple of lines.
And show some code!
CodingLover wrote: data adding start on a button click
What button? Or do you mean the tab of a tab page?
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
modified on Sunday, June 12, 2011 8:09 AM
|
|
|
|
|
Hi,
forgot to mention: if you need to add lots of items to a listing Control such as a ListView, don't
forget to call SuspendLayout beforehand, and ResumeLayout when you are done adding. Otherwise the
Control will re-evaluate its looks after every single addition, making it extremely slow.
BTW: this should not matter if you were to use data binding.
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
modified on Sunday, June 12, 2011 8:09 AM
|
|
|
|
|
I have a scenario where I have an application that allows a user to open mulitple documents on different tabs within the application.
If the application is already running and the user opens a file associated with my application from Windows Explorer, how can I get the document to open in the instance of my application that is already executing as opposed to opening a new instance of the application?
I have seen posts that check whether or not a process / application is already running. In the examples I have seen, if the application is already running a messagebox is just displayed indicating as such. However, in my case, I need to assign the document to the executing instance of the application.
Any help would be appreciated?
|
|
|
|
|
Hi,
you need two things:
1.
the logic to detect more than one instance got launched; so the extra instances can eventually exit again.
2.
a way to pass the command line of a second instance to the first instance. That is interprocess communication, there are many ways to do it. The way I typically do this consists of:
- a named pipe, that gets created using the Win32 function CreateFile (yes that takes P/Invoke) and a fixed name;
- WriteFile to send the command line of a second instance
- a thread on the first instance, performing a ReadFile on the same pipe, and acting on anything that
comes in.
WARNING: there is a security hole: any program could now send a string to your first instance (however
any program could launch your app with some command line too).
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
modified on Sunday, June 12, 2011 8:10 AM
|
|
|
|
|
Hello,
I have a string of the form 12.4454554, when I want to convert to float, one exception: the format of the input string is incorrect,
I use this :
float.Parse(my string);
how to convert my string to Float (two numbers after the comma)? thank you very much.
|
|
|
|
|
Here is only the quick'n'dirty version:
string tmp = "12.4454554";
tmp= tmp.Replace('.', ',');
double rounded= Math.Round(System.Convert.ToDouble(tmp), 2);
for a clean solution have a look on IFormatProvider.
[edit]
string tmp = "12.4454554";
double rounded= Math.Round(System.Convert.ToDouble(tmp,System.Globalization.CultureInfo.CreateSpecificCulture("en-us")), 2);
works too..
modified on Sunday, February 15, 2009 7:04 PM
|
|
|
|
|
Hi
i want to create a user control and add some other controls to it.
for example add a button to my userControl and let user to interact with this button at runTime (for example, allow user to click on it) and customzie it at designTime (for example, create event handler for click event), but when i drag userControl to my form, child controls did not have any interactivity behavior.
how to do that ?
thanks
modified on Sunday, February 15, 2009 5:55 PM
|
|
|
|
|
I tried the following, an it worked:
made a winform and placed a panel on it.
Than added a Button with somethink like this:
private void button1_Click(object sender, EventArgs e)
{
Button btn = new Button();
btn.Click += new EventHandler(btn_Click);
panel1.Controls.Add(btn);
}
void btn_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
Or did you mean someting different?
|
|
|
|
|
Hi Nico
i tried it also and my problem has been solved.
thanks
|
|
|
|
|
If you want to, for example, handle the click event of a button on a usercontrol, you should be handling it in the usercontrol code - nit in the form on which ou put the user control.
Similarly,if you want to design the button, you deign it in your user control.
If you want to be able to reuse your user control with, say, a different font on the button, then you need to add a property to your user control (lets call it ButtonFont) and write the Setter and Getter to access the Button's Font property.
If you REALLY want to access the button itself outside of the user control, at runtime e.g. you want code that says
MyUserControl1.OKButton.Text = "Hello";
then you need to set the Button's 'Modifiers' property in the user control to Public - so you can access it. This is not good practice, though, better to hide the button itself, and allow access only to those properties you want to give access to.
Similarly if you want to handle the click event of the button on the user control from within your form, you need to add an event to your user control - raise the event when the button is clicked. Thus the form doesn't know it was necessarily a button click event, just that the user control is telling it that some event has occurred.
For example - if your UC is used to select from a list of items, you might allow the user t double click on an item, selec the itme th click OK,select the item and press enter, click on a linklabel - etc. etc.
By raising a single event from the user control, the 'user' of tat control doesn't need to worry about what caused the event to fire - it just needs to know that it needs to handle the event because it has been raised.
Sorry for the rambling - this is a big subject & it depends on your requirements as to what you need to do for the best.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
|
I have a this case...
using System;
namespace FirstGenericClass
{
public classCounter
{
private int count;
public int Counter
{
get{ return count; }
}
public void Increament()
{
count++;
}
}
}
Here i want to write 2 classes, first one as a query class and the second one as a command class. How do I go about that
|
|
|
|
|
What do you want to query , and what do you want to command? So far all you have is an Int32 wrapper that has an increment method...
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)
|
|
|
|
|
You write code. What was your question ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
If u nt gona answer the question, plz keep the f-up answers to yo self. A-hole
|
|
|
|
|
Member 3916856 wrote: the f-up answers to yo self. A-hole
Good way to alienate yourself. Good luck getting anyone to answer with an attitude like that.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
I'm dearly sorry about my reply. But at time a person is just looking for an answer. You can just say when you not understanding the question
|
|
|
|
|
Hi AnyBody help me.....
In my project need a schedule a program with in a clock, so i decided to create
a clock circle and if drag and drop the some program in clock(Circle)that is added
to the particular clock time.so need idea to GUI design , if i drag a program to clock
that program duration only have different color ,like wise all program are displayed different color. And main important is if i need to changr or remove the program means
click that the color and drag and drop to the out sideof the circle, that program will removed from the circle . how can i do this give some idea.... I more expecting from you.
ThankYou
|
|
|
|
|