|
it's return true. i sure that. 
|
|
|
|
|
hi
i want to develop a mini messaenger in xmpp with conversation tabpage, Emotion panel.
i can duplicate tabpage by clicking " Add " button in my form. when i duplicate 2,or ... tabpage . and when i click show panel, panel dont visible in my current tabpage and visible in other tabpage(in last tabpage), i uploaded my project :
http://www.megafileupload.com/en/file/541739/tabpage-rar.html[^]
help me to slove problem
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace tabpage
{
public partial class Form1 : Form
{
private System.Windows.Forms.Panel pan;
private System.Windows.Forms.Button bt;
private System.Windows.Forms.PictureBox im1;
private System.Windows.Forms.PictureBox im2;
private System.Windows.Forms.PictureBox im3;
private System.Windows.Forms.TabPage tp;
public Form1()
{
InitializeComponent();
}
private void duplicate()
{
this.pan = new System.Windows.Forms.Panel();
this.bt = new System.Windows.Forms.Button();
this.im1 = new System.Windows.Forms.PictureBox();
this.im2 = new System.Windows.Forms.PictureBox();
this.im3 = new System.Windows.Forms.PictureBox();
this.tp = new System.Windows.Forms.TabPage();
pan.Location = new Point(201, 6);
pan.Size = new Size(140, 146);
pan.BackColor = Color.Gray;
pan.Visible = false;
bt.Location = new Point(235, 158);
bt.Text = "show";
this.bt.Click += new System.EventHandler(this.bt_Click);
im1.Size = new Size(25, 25);
im1.Location = new Point(3, 3);
im1.Image = Properties.Resources._16_circle_green;
im1.SizeMode = PictureBoxSizeMode.CenterImage;
im2.Size = new Size(25, 25);
im2.Location = new Point(30, 3);
im2.Image = Properties.Resources.delete__166_;
im2.SizeMode = PictureBoxSizeMode.CenterImage;
im3.Size = new Size(25, 25);
im3.Location = new Point(57, 3);
im3.Image = Properties.Resources.down;
im3.SizeMode = PictureBoxSizeMode.CenterImage;
tp.Controls.Add(pan);
tp.Controls.Add(bt);
pan.Controls.Add(im1);
pan.Controls.Add(im2);
pan.Controls.Add(im3);
tabControl1.Controls.Add(tp);
}
private void bt_Click(object sender, System.EventArgs e)
{
if (bt.Text == "show")
{
pan.Visible = true;
bt.Text = "hide";
}
else if (bt.Text == "hide")
{
pan.Visible = false;
bt.Text = "show";
}
}
private void button1_Click(object sender, EventArgs e)
{
duplicate();
}
}
}
http:
modified 15-Jun-14 5:25am.
|
|
|
|
|
Don't post the same thing in multiple places: it wastes time and annoys people.
You have this in QA, leave it there.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
namespace AddItemInComboBox
{
public partial class Form1 : Form
{
const string conString = "Data Source=ABHINANDANCOMPU;Initial Catalog=Color;Integrated Security=True";
public SqlConnection con = new SqlConnection(conString);
public SqlDataAdapter da = new SqlDataAdapter();
public DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
cmbCompany.DataSource = null;
ComboBoxAddData("companyName", "companyId");
}
private void ComboBoxAddData(string DisplayMember, string ValueMember)
{
cmbCompany.DataSource = null;
cmbCompany.Items.Clear();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("SELECT [companyId],[companyName] FROM tblMasterCompany", con);
con.Open();
da = new SqlDataAdapter(cmd);
da.Fill(ds, "tblMasterCompany");
cmbCompany.DataSource = ds.Tables["tblMasterCompany"];
this.cmbCompany.ValueMember = "companyId";
MessageBox.Show("Add SuccessFully");
da.Dispose();
con.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO tblMasterCompany ([companyName] ,[address] ,[city]) VALUES ('" + txtCompanyName.Text + "', '" + txtAddress.Text + "', '" + txtCity.Text + "')", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Save ");
con.Close();
Form1_Load(sender, e);
}
}
}
modified 15-Jun-14 3:39am.
|
|
|
|
|
First off, format that code so we can tell what is going on: edit the question, ands use <pre>...</pre> tags round it to preserve the formatting.
Then try explaining in more detail in the question itself what you are doing to cause the problem and what effects it is having: Remember that we can't see your screen, access your HDD, or read your mind!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
sir i want refresh list in combo box after create a new item
|
|
|
|
|
Please, read what I said in the previous message, and do that.
I am not looking at your code while you make it difficult for me!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
private void ComboBoxAddData(string DisplayMember, string ValueMember)
{
//
combo box cmbcomapny is not refresh Item list It just Add Item Again and again
cmbCompany.DataSource = null;
cmbCompany.Items.Clear();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("SELECT [companyId],[companyName] FROM tblMasterCompany", con);
con.Open();
da = new SqlDataAdapter(cmd);
da.Fill(ds, "tblMasterCompany");
cmbCompany.DataSource = ds.Tables["tblMasterCompany"];
this.cmbCompany.DisplayMember = "companyName";
this.cmbCompany.ValueMember = "companyId";
MessageBox.Show("Add SuccessFully");
da.Dispose();
con.Close();
}
|
|
|
|
|
Is it displaying the data from the database or the name of the dataitem. Check the spelling (capitalisation) of your display and value member fields.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
private void ComboBoxAddData(string DisplayMember, string ValueMember)
{
// - > COMMENT LINE FOR DETAILING OUR CODE
// PROBLEM IS combo box cmbcomapny is not refresh Item list AFTER WE SET NULL VALUE IN +
// + COMBO BOX DATA SOUCE
// IT NOT CLEAR OLD LIST AND ADD NEW LIST BELOW THEIR WHEN THIS FUNCTION CALL
// cmbCompany IS A COMBO BOX
// cmd IS A SQL COMMAND WHICH SELECT TWO FILED 1 -> COMPANYID AND 2-> COMPANY NAME FROM tblMasterCompany (TABLE NAME)
// con IS A CONNECTION
cmbCompany.DataSource = null;
cmbCompany.Items.Clear();
SqlCommand cmd = new SqlCommand("SELECT [companyId],[companyName] FROM tblMasterCompany", con);
con.Open();
da = new SqlDataAdapter(cmd);
da.Fill(ds, "tblMasterCompany");
cmbCompany.DataSource = ds.Tables["tblMasterCompany"];
this.cmbCompany.DisplayMember = "companyName";
this.cmbCompany.ValueMember = "companyId";
MessageBox.Show("Add SuccessFully");
da.Dispose();
con.Close();
}
|
|
|
|
|
Down vote countered.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: Down vote countered
And then some - I have the power thanks
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you want to refresh the page, You can Try this.
under the function of ComboBoxAddData() call Form1_Load(null,null). Now You can bind the your ComboBox will null values.
Plz check it.
|
|
|
|
|
So as mentioned, I'm trying to make a list of people connected but you have to first add that person, having done that, that person will appear in your listbox.
And another question, is to make a private chat, using the Network API.
The network api dll that I use is this:
Click here to download.
Thank you all.
|
|
|
|
|
|
After reading some article on performance and reading some of the .NET source code I am trying to reduce memory allocation and boxing as much as possible. Particularly in methods which are going to be called repetitively.
Now I know that foreach (var item in collection) works just as well and is more readable that
for (int i = 0; i < collection.Count; i++).
But I wonder foreach callGetEnumerator() which must return some new ThatEnumerator() which allocate an object!
So, a couple of nested foreach, bang, allocation, then GC, then slow down!
Any comments on that?
|
|
|
|
|
Any foreach loop has two extra variables on the stack, so while running foreach loop takes more memory and may be a bit slower...
The GetEnumerator problem is exist only if your enumerator is a class. In the .NET System.Collections.Generic namespace all collections (List<T>, Dictionary<TKey, TValue>)) implementing enumerator as a structure so it does not allocate memory on the heap, but returns a reference to an existing object...
If you want to reduce the memory peak and GC runs, try to use standard collections or build yours along the same line...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
modified 14-Jun-14 16:20pm.
|
|
|
|
|
Seems like part of your post got eaten
|
|
|
|
|
Thank you - fixed it...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Don't sweat the small stuff. I never worry about Garbage Collection; that's the point of having it.
I prefer to use for when I can, but I'm old-school that way.
Super Lloyd wrote: nested foreach
I don't think I've ever needed that.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I am not too worried..
But I am writing custom Panel (for WPF) which will be in hierarchical resizable items controls...
And they will do multi pass layout too...
Hence I am going to do a lot of recursive call on every mouse move events...
So far it's very quick and I am not really worried!
However I can't help to see how, in the .NET source code, they use struct as much as possible in such case and even use an internal BooleanBoxes to optimize boxing away for DependencyProperty(ies)...
And I though if I could reduce boxing and memory allocation in my panels, that would be nice too!
And I noticed the foreach => GetEnumerator() and was wondering about it!
It's not micro optimization, as this is a process on its own which has no link with anything else. But it will be a process that will be called regularly, why not spend 1 more hour to make it better?
At any rate.. I am using for loop now and only struct in my layout code and I reuse the same array, when I need one!
So memory wise it's good enough!
|
|
|
|
|
I think I'd be more concerned about the recursion.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Well, it can't be helped!
RibbonBars contains RibbonGroups which contains RibbonItems which contains Header!
(And MenuItems contains sub MenuItems which contains Header too)
Yeah I am making my own Ribbon library! But wait, there is a twist, it's called... MenuRibbon! And most ItemsControl in it have no particular container type! :P
|
|
|
|
|
Use the for loop .
I rarely use the foreach, because despite your personal feeling of being more readable, I find it less readable. (especially in the sense of what it is doing).
|
|
|
|
|
Using it now!
BTW, in some structure (say linked list for example) it is not really practical to use the for loop!
|
|
|
|