|
Hi
I have a form with 3 list controls. i have filled all the controls using the same dataset. when i try to select a first item in the first list box, the corresponding first item in the 2nd and 3rd list box controls getting selected. Why i'm getting this issue?
Thanks in advance
regards
sri
|
|
|
|
|
Because they all have the same data source. Use the Clone method on your data source to make copies, and then when each control has it's own copy, the problem will go away.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks a lot Christian Graus
|
|
|
|
|
Hi All,
Can anyone tell me How to prevent MDI child from maximizing in c#
Thanks in Advance
~Pramod
|
|
|
|
|
hi pramodgupta24,
U can set child form property Maximize box to false.....
|
|
|
|
|
Can anybpdy tell me why we are using Serialization , if we can save the data directly to data base... then what is the use of saving it on hard disk
Thanks in advance
vikas da
|
|
|
|
|
Not every app, needs a database.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
can you please tell me like where it can be used in real time ...
vikas da
|
|
|
|
|
For example, I have a program where we use serialization to store a list of class instances that we want to be able to change by simply changing the config file, in an app that has no database.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Some examples where serialization can be uses:
* Load / Save documents in your app (where each document is object based)
* App configs / settings
* Offline data in smart clients
* As a file based queue before you write data to a DB
|
|
|
|
|
How do I fix this mess!! trying to C# programme which displays changing minutes and seconds, representing them by two long rectangles, maximum width of rectangle equal to 600 pixels (10 pixels for each minute and each second). redraw the two rectangles every second. please help!!!!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private Random randomNumber = new Random();
//private void timer1_Tick();
private Graphics paper;
public Form1()
{
InitializeComponent();
paper = progressBar1.CreateGraphics();
timer1.Interval = 600;
timer1.Enabled = true;
//count = count + 1;
//label1.Text = Convert.ToString(count / 60);
}
private void start_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void stop_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void clear_Click(object sender, EventArgs e)
{
paper.Clear(Color.White);
}
private void timer1_Tick(object sender, EventArgs e)
{
//int x = 5;
//int y = 20;
int x, y, size;
Brush myBrush = new SolidBrush(Color.Black);
x = timer1.Tick+= progressBar1.Width;
y = timer1.TickGetType+= progressBar1.Height;
size = randomNumber.Next(1, 60);
paper.FillRectangle(myBrush, x,y,size,size);
|
|
|
|
|
ketto wrote: paper = progressBar1.CreateGraphics();
Disaster. Handle the paint event and invalidate your form in the tick event instead.
ketto wrote: size = randomNumber.Next(1, 60);
If it's a clock, why does it move randomly ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
any suggested alterations on this code???
|
|
|
|
|
Well, I'd say read up on the paint event and start again. If this is meant to be a clock, I can only assume you copied it from somewhere and you're trying to change it to work as a clock ? Start from scratch.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
yes I did copy frpm some where and I thought it would guide me in getting what am trying to do. I now can't make sense of what am trying to do hence my post
|
|
|
|
|
Funny, I got a 1 and a 5 in the same thread....
Copying code you don't understand is never a good start. Someone posted code that should do all of what you want. I'd have preferred to walk you through it bit by bit, but you have the code on this thread, now I recommend you take the time to study it and research the bits you don't understand, so you learn from it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private Brush myBrush;<br />
private Graphics paper;<br />
<br />
private const int barWidth = 40;<br />
<br />
int seconds, minutes;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.myBrush = new SolidBrush(Color.Black);<br />
this.paper = pictureBox1.CreateGraphics();<br />
<br />
this.timer1.Interval = 1000;<br />
<br />
this.seconds = 0;<br />
this.minutes = 0;<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
this.timer1.Start();<br />
}<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
this.timer1.Stop();<br />
}<br />
<br />
private void timer1_Tick_1(object sender, EventArgs e)<br />
{<br />
this.paper.Clear(SystemColors.Control);<br />
<br />
if (this.seconds < 60)<br />
this.seconds++;<br />
<br />
else<br />
{<br />
this.seconds = 0;<br />
this.minutes++;<br />
}<br />
<br />
paper.FillRectangle(myBrush, 0, 0, (seconds * 10), barWidth);<br />
paper.FillRectangle(myBrush, 0, 60, (minutes * 10), barWidth);<br />
}<br />
}<br />
}<br />
modified on Tuesday, April 29, 2008 1:25 AM
|
|
|
|
|
MarkBrock wrote: this.paper = pictureBox1.CreateGraphics();
This still sucks.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Just for you Christian .
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private Brush myBrush;<br />
<br />
private const int barWidth = 40;<br />
<br />
int seconds, minutes;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.myBrush = new SolidBrush(Color.Black);<br />
<br />
this.timer1.Interval = 100;<br />
this.timer1.Enabled = true;<br />
<br />
this.seconds = 0;<br />
this.minutes = 0;<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
e.Graphics.FillRectangle(myBrush, 0, 0, (this.seconds*10), barWidth);<br />
e.Graphics.FillRectangle(myBrush, 0, 60, (this.minutes * 10), barWidth);<br />
<br />
base.OnPaint(e);<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
this.timer1.Start();<br />
}<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
this.timer1.Stop();<br />
}<br />
<br />
private void timer1_Tick_1(object sender, EventArgs e)<br />
{<br />
this.Invalidate();<br />
<br />
if (this.seconds < 60)<br />
this.seconds++;<br />
<br />
else<br />
{<br />
this.seconds = 0;<br />
this.minutes++;<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Lovely
CreateGraphics has it's place, but it gets misused a lot, and a clock is surely something that could get obscured, even if it does repaint itself every second.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hey ketto
i see your new to this forum, would you please put code in your future posts in code and pre tags... especially if you posting quite a few lines of code...
the reson for this is to keep the formatting (indentation)... EG
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 WindowsFormsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
now doesnt that look better?
good luck with your problem
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
I am really new as u can tell from question. New in programming indeed. thanks for your guidance
|
|
|
|
|
Good Day,
Say I have an array of numbers. For instance:
int[] myNumber = {1,11,21,42,32};
and I would like to randomly remove 2 items from that array. It is easy to implement, but mine was sort-of inefficient (I'm working with large arrays). So I'm asking for some advice.
Thanks.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
Ian Uy wrote: like to randomly remove 2 items from that array. It is easy to implement, but mine was sort-of inefficient (I'm working with large arrays).
Let's see the code, how can where is it being inefficient?
"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
|
|
|
|
|
Well, what I do is first I get the size of the array, say 10, then randomly generate a number from 1 to 10, then check if the number generated has already been removed, if not, generate again, if yes, remove it. So it's like a guessing game.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|