|
I have 2 SplitContainers(splitContainer1 and splitContainer2) in the WinForm. Both orientation is Horizontal, Dock is Fill. splitContainer2 in the panel1 of splitContainer1 .
When panel2 of splitContainer1 cover of the panel2 of splitContainer2, splitContainer2 is not resize.
why? how to do? thanks. And I want the panel1 of splitContainer1 is not fixe.
|
|
|
|
|
I'm slightly confused about the way the problem is explained and presented.
I get the first bit : You have two splitcontainers, each horizontally orientated and you've put Split2 in Panel 1 of Split1.
The second bit is what confuses me. Could you please refraise that sentence for me. I'm not sure what you're trying to achieve.
|
|
|
|
|
Drag Split1's Splitter. Display only one panel of the Split2.
If Split1's resize event fire in this time, Split2 not resize.
why do the split2 not resize?
how to solve?
But I dont want to fixed size of the panel of the Split1 which contains split2.
|
|
|
|
|
Hi all,
In my c# application i.e., windows application i am using a combobox and in its collection properties i have added some data.
When ever i run my application in combobox it doesn't show any default value,its shown empty until it is selected.
How can i shown default value in combobox in windows application ?
Thanks in advance.
|
|
|
|
|
In the designer, you can set comboBox1.Text = "First Item"; or you simply display the first item in your collection in the e.g. form load event.
|
|
|
|
|
Use combobox SelectedIndex to select the default value in the combobox
|
|
|
|
|
When you're application loads, or when the combobox is filled, use this :
comboBox.SelectedIndex = 0;
|
|
|
|
|
The two answers above me are correct in different cases. If the DropDownStyle is DropDown (i.e. drop/edit), set the Text property to have an initial value. If it is DropDownList, set SelectedIndex (or SelectedItem). You should do this after InitialiseComponent is called; I typically do it lower down in the form class constructor.
Alternatively, if you data bind the combos, they will initialise to the initial value of the property to which they are bound.
|
|
|
|
|
this code may help you..
private void loadComboBox()
{
if (this.cmb.DataSource == null)
{
this.cmb.Items.Add("Please Wait");
this.cmb.Text = "Please Wait";
this.cmb.Refresh();
}
DataTable tbl = comboData() as DataTable;
tbl.Rows.Add(0, "<Select>");
cmb.DataSource = tbl;
cmb.DisplayMember = "Name";
cmb.ValueMember = "Id";
cmb.SelectedValue = 0;
}
|
|
|
|
|
HI,
I have arraylist and the first item in array represent time , the number of message in array may be reach up to 10,000 messages , so if I have messages reached to 2000 message the message number 20001 is set to 0 and when I try to get the total time I have problem because the total is the final element.
some issues :-
- if message set to zero after number of message I will consider the past time is 3640 seconds and so on.
total time = 3640 + the last element in the last in the next items.
- if number of message not set to zero the end item will represent the total time.
<br />
for (int j = 0; j < numberOfMessagesInSection; j++)<br />
{<br />
<br />
nextValue = int.Parse(MessageTimeAssociation[next + 1].messagebytes[0]);<br />
<br />
if (nextValue >= int.Parse(MessageTimeAssociation[j].messagebytes[0]))<br />
{<br />
totalSectionTime = int.Parse(MessageTimeAssociation[numberOfMessagesInSection - 1].messagebytes[0]);<br />
<br />
}<br />
else<br />
{<br />
<br />
totalSectionTime += 3640;<br />
<br />
}<br />
this my code but my problems appears in this cases :-
if the arraylist contains few messages the total time should be the final element but this code not achieve it.
|
|
|
|
|
This has a bad code smell about it that can be detected from the moon, and that's made of cheese.
Honeyboy_20 wrote: I have problem because the total is the final element.
So don't do that then.
The main problem with this is how you are representing your data: ArrayList has almost zero use since generics came out. You might need a List<Message> or HashSet<Message> or possibly Queue<Message> it depends on what you are doing, even then other collections might be more appropriate. In any case storing multiple object types the way you have described it in an ArrayList is a recipe for disaster, you should:
Create a new class to store your data
Add the appropriate Generic collection as a property (make the property read-only: you can still add items externally)
Add properties to store any timings you need
I don't fully understand your problem, but whatever it is this should provide a start.
|
|
|
|
|
I ask about condition as logical if you can help ok or stop.
|
|
|
|
|
His answer is valid. Your code doesn't make any sense at all and your description of the problem only adds to the confusion. How does the number of bytes in a message relate to a time value? Why?
|
|
|
|
|
He was being helpful. Keith is one of the good guys. I wouldn't have been as gentle.
Rather than throwing a hissy fit, you should ask yourself why he replied in this manner. Perhaps then you could actually learn and grow as a developer.
|
|
|
|
|
Thats one of the things I like about the code project, you might not get the answer you want but someone will give you the answer you need.
I doubt anyone will understand what you wanted, it certainly isn't clear from the code. When this happens, irrespective of who writes it, it means than more than likely the code has a design flaw. Fix the design flaw first and quite often the problem you are having dissapears or become easy to spot.
|
|
|
|
|
Stop being an ass hat...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Keith Barrow wrote: that's made of cheese
limburger?
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Where did the 'next' and 'numberOfMessagesInSection' come from?
You're using it in the statment but none of us know how they are declared or how they're being used.
|
|
|
|
|
I was confused when I read this question the first time.
Then I was even more confused when I read it the second time.
I don´t like to read this question a third time.
I cannot remember: What did I before google?
|
|
|
|
|
Dear all
I am brand new to C# and have previously only written programs in Javascript, so go easy on me !
I have written an "app launcher" program which reads a text file line by line. Each line is just a path to a program e.g. C:\Users\Matt\Desktop\Gravity.exe
So far, my program can successfully read each line and produce a list of links. As intended, each link appears as the path itself.
The problem I am having is that these links will not work. However they WILL work if they are all just given the same fixed path. I would like each link to use its .Text property as the destination. (please see the comments "works" and "does not work" in my code below). The only error I get is "cannot find the file specified".
I would really appreciate any help on this as I am finding C a lot harder than Javascript !
Thank you
Jim
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO; //for reading a text file
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) //on form load
{
int counter = 0;
string line;
string myfile = @"c:\users\matt\desktop\file.txt";
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader(myfile);
while ((line = file.ReadLine()) != null)
{
//MessageBox.Show(line); //check whats on each line
LinkLabel mylinklabel = new LinkLabel(); //LinkLabel tells us the type of the object e.g. string mystring ="hello";
mylinklabel.Text = line;
this.Controls.Add(mylinklabel);
mylinklabel.Location = new Point(0, 30 + counter * 30);
mylinklabel.Click += new System.EventHandler(LinkClick);
counter++;
}
file.Close();
}
private void LinkClick(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start(this.Text); //doesn't work
//System.Diagnostics.Process.Start(@"C:\Users\Matt\Desktop\gravity.exe"); //works
}
}
}
|
|
|
|
|
Hi,
welcome to CodeProject.
Please use PRE tags correctly to show code snippets. You could still edit the existing message.
Your problem is this:
in System.Diagnostics.Process.Start(this.Text); this refers to the instance of the class it is in, i.e. to your Form, and not to the specific LinkLabel you are hoping it refers to. To get that, try this:
LinkLabel link=sender as LinkLabel;
if (link!=null) System.Diagnostics.Process.Start(link.Text);
I also suggest you add some error handling, so you get a decent response when the file doesn't exist.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Good answer. To provide a little more help to the newbie who asked the question: In C#, the convention (and what IDEs produce) is that event handlers are written in the form class, so this refers to the form and not to the source of the event. The sender parameter is the source of the event (e.target, to make a JavaScript analogy), but you will need to cast it to a type that you know it must be.
In addition, for event handlers which are fired only off one control, you can simply refer to that control in the event handler. E.g.
LinkLabel myLinkLabel;
Form1(){
myLinkLabel = new LinkLabel();
myLinkLabel.Text = "/thing.exe";
myLinkLabel.Click += (s,e) => {
Process.Start(((LinkLabel)s).Text);
};
}
(I wrote the event handler as a lambda delegate, for .Net 3.0 and up, but the same things apply if you write it as a normal method.)
Edit: ... but missed out the semicolon at the end of the delegate assignment.
modified on Tuesday, May 3, 2011 10:40 AM
|
|
|
|
|
See this wud work for sure
System.Diagnostics.Process.Start(((LinkLabel)sender).Text);
modified on Thursday, May 5, 2011 5:58 AM
|
|
|
|
|
It's bad enough having questions in txtspeak. Answers should be in grammatical English.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Sorry Sir i am just new at it
modified on Thursday, May 5, 2011 6:11 AM
|
|
|
|