|
Hello,
I would like label control with fixed width but length should increase as per the text data. OR run time how can I control label control's width and height depending on text of label control.
Thanks & Regards,
Kumar
|
|
|
|
|
Hello Kumar,
If you would like your label's width to increase depending on the text property of the control, simply set the AutoSize property to true.
By default in VS 2008 this property will be set to true
|
|
|
|
|
Hi Corayzon,
This I had tried, but it is increasing form width also. I want form width should be fixed like 300 and label's text should be wrap to next line.
Thanks & Regards,
Kumar
|
|
|
|
|
Hi,
I have solved using Graphics.measurestring wih 3rd parameter as fixed width.
Thanks & Regards,
Kumar
|
|
|
|
|
Ya thanks Kumar,
Measurestring really helped it.
IF any one wants the code snippet :
int iTop = 0;
for (int icounter = 0; icounter < someCollectionObject.Count; icounter++)
{
Label lblctrl = new Label();
lblctrl.Name = "lbl" + icounter.ToString();
lblctrl.Image = "Put the image locaiton here "
lblctrl.ImageAlign = ContentAlignment.TopLeft;
string txtToShow = string.Empty;
txtToShow = " " + someCollectionObject[icounter];
lblctrl.Text = txtToShow;
lblctrl.Font = new System.Drawing.Font("Arial", 7f, System.Drawing.FontStyle.Bold);
lblctrl.ForeColor = Color.LemonChiffon;
lblctrl.Top = iTop;
Graphics g = Graphics.FromHwnd(this.Handle);
SizeF sz = g.MeasureString(txtToShow, lblctrl.Font, 100);
lblctrl.Width = "You can have any constant width you wanted";
lblctrl.Height = (int)sz.Height -10;
iTop += lblctrl.Height;
}
|
|
|
|
|
Hello All,
I am currently building an easy to use file transfer client that uses UDP to broadcast across the local network with an username and TCP port that is accepting connections on that host. So each user will automatically see every other users on that network without having a central server to pass client details around. Upto this point it works fine, and i am able to transfer files and so forth, no worries.
My problem.
I want users to have the ability to drag files\directories from a users file list which is displayed in a Forms.ListView object to windows explorer which will then start the transfer process within my application and store the selected files in the drop location within windows.
So...
* Client connects to remote host and retrieves directory listing
* Client displays the remote hosts files in a listview
* User drags files from file listing to explorer
* My application then starts the file transfer process and stores the files at the drop location
Help would be much appreciated and commented in the about dialog for the application.
|
|
|
|
|
|
Does anyone know where i can get free icons for my software. Also is it legal to incorporate the window icons into your software. Things like open, save....
|
|
|
|
|
Visual Studio has a folder with icons you can use, otherwise, just google, that's all I ever do.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
I've used google to search for free icons in the past and have found some nice ones
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
try to search "tango images" on google. The're many great and catchy icon / images with GNU licence
No one can prevent me to learn something
|
|
|
|
|
Hi All,
Can someone plz give me an example about how to manipulate data from Ms-Access 2003 db into C# windows form text boxes, such as select, insert and update.
Thanks very much in advance.
|
|
|
|
|
Andie
There are so many articles and resources on CP and the net that a simple search should give you literally 1000s of examples.
Once you have a connection clickety[^] you retreive the data use sql statements and use the resulting data sets to bind to the controls.
Do some research.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i already did a lot of search and couldn't get any, sorry for my poor research skills, and if u can give me a few links would be great.
Cheers
|
|
|
|
|
How can you possibly say you have done a lot of research, my first attempt clickety[^]
There is enough material here meet anyone needs.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I wrote an article on how to use google, perhaps you should read it ? It's here on Code Project.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: I wrote an article on how to use google
Nice one, too. Having good research skills is rather helpful
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
What have you attempted ?
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I have a datagridview that has data in 2 columns that I would like to make into a list (Column [1] and Column[2])
I have been trying...
for (int i = 0; i < dgv2.RowCount - 1; i++)
{
x = (dgv2.Rows[i].Cells[1].Value.ToString());
y = (dgv2.Rows[i].Cells[2].Value.ToString());
}
This works for string values but Column 1 is a Date value and Column 2 is a float from an SQL db, and I need to convert them to double.
It seems to be iterating through the DGV ok but I am not sure how to get the data converted.
Can someone point me in the right direction??
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Assuming that you added data to the DataGridView column as integers then you can try this:
int Column1Index = 5; // zero based index to column 6 in dgv2
int Column2Index = 7; // zero based index to column 8 in dgv2
int[] Column1 = new int[dgv2.Rows.Length];
int[] Column2 = new int[dgv2.Rows.Length];
for (int i = 0; i < dgv2.Rows.Length; i++)
{
Column1[i] = (int)dgv2.Rows[i].Cells[Column1Index].value;
Column2[i] = (int)dgv2.Rows[i].Cells[Column2Index].value;
}
If your DataGridView columns hold strings then just change the arrays and casts to use strings instead of ints.
Hope it helps
|
|
|
|
|
I think you just made the lights come on. So is this how I would cast to double??
x = ((double)dgv2.Rows[i].Cells[1].Value);
y = ((double)dgv2.Rows[i].Cells[2].Value);
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Yes. The .Value member of the Cells collection is just a simple object so you can copy just about anything into it. The trick is remembering the type you put into each column so you can cast it properly when you get it back out. Also, it works better to not convert everything to strings before you put them into the DataGridView as a double or int converted to a string certainly won't sort the same as the original double or int values would.
|
|
|
|
|
|
I have a program that I'm developing for a class. I have to generate 10,000 random 3 digit numbers and keep track of how often each one comes up. Once complete the program should display 10 most common and the 10 least common numbers. The problem I'm facing is that when I run the program it seems to just run for a long time and than after a few minutes throws an out of index error at line 50 which reads as such lotteryNumbers[i, 1]++;. I have included my code below. Anyone have any ideas of what I'm doing wrong with the array and how I might speed up the application. My guess is that the looping is causing the slowdown but want to be sure as I cannot get to compile either way.
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;
namespace William_Cappoli_IT466_Unit_3_Project
{
public partial class frmMain : Form
{
int[,] lotteryNumbers = new int[1000, 2];
int[,] maxNumbers = new int[10, 2];
int[,] minNumbers = new int[10, 2];
int currentNum;
Random randomNumbers = new Random();
public frmMain()
{
InitializeComponent();
fillLotteryArray();
}
private void btnGenerate_Click(object sender, EventArgs e)
{
fillMinNumbersArray();
lblDisplayMostCommon.Text = "";
lblDisplayLeastCommon.Text = "";
for (int i = 0; i < 10000; ++i)
{
currentNum = randomNumbers.Next(999);
for (int j = 0; j < 1000; ++j)
{
if (lotteryNumbers[j, 0] == currentNum)
{
lotteryNumbers[i, 1]++;
}
}
maxNumber();
minNumber();
}
}
private void fillLotteryArray()
{
for (int i = 0; i < 1000; ++i)
{
lotteryNumbers[i, 0] = i;
}
}
private void fillMinNumbersArray()
{
for (int i = 0; i < 10; ++i)
{
minNumbers[i, 1] = 5000;
}
}
public void maxNumber()
{
for (int j = 0; j < 1000; ++j)
{
for (int i = 0; i < 10; ++i)
{
if (lotteryNumbers[j, 1] > maxNumbers[i, 1])
{
for (int h = 9; h > i; --h)
{
maxNumbers[h, 1] = maxNumbers[h - 1, 1];
maxNumbers[h, 0] = maxNumbers[h - 1, 0];
}
maxNumbers[i, 1] = lotteryNumbers[j, 1];
maxNumbers[i, 0] = lotteryNumbers[j, 0];
i = 10;
}
}
}
for (int i = 0; i < 10; ++i)
{
lblDisplayMostCommon.Text += maxNumbers[i, 0].ToString("000") + " " + Convert.ToString(maxNumbers[i, 1]) + "\n";
}
}
public void minNumber()
{
for (int j = 0; j < 1000; ++j)
{
for (int i = 0; i < 10; ++i)
{
if (lotteryNumbers[j, 1] > 0 & lotteryNumbers[j, 1] < minNumbers[i, 1])
{
for (int h = 9; h > i; --h)
{
minNumbers[h, 1] = minNumbers[h - 1, 1];
minNumbers[h, 0] = minNumbers[h - 1, 0];
}
minNumbers[i, 1] = lotteryNumbers[j, 1];
minNumbers[i, 0] = lotteryNumbers[j, 0];
i = 10;
}
}
}
for (int i = 0; i < 10; ++i)
{
lblDisplayLeastCommon.Text += minNumbers[i, 0].ToString("000") + " " + Convert.ToString(minNumbers[i, 1]) + "\n";
}
}
}
}
Thanks
|
|
|
|