|
Hello!
It's been only a few weeks since I have started to learn WPF, and I came across some assignments that needed color changing in the images being generated. For this, I was able to use radio buttons and get away with it, but I am interested to find out about using colour pickers.
Any idea as to how? Please share with me. I would appreciate it if the app is really simple though, because I am just an enthusiastic beginner.
|
|
|
|
|
You mean something like this[^] one?
|
|
|
|
|
Yes, something like that, but much simpler, so that a beginner can grasp the idea behind it.....
|
|
|
|
|
I don't think you're going to get anything WPF based that's much simpler than that.
|
|
|
|
|
I have to agree with Pete on this one.
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
Look at the mouse move event on the colour picker control, that's where the 'magic' happens.
And ew, Sasha uses empty catch blocks? heh.
|
|
|
|
|
Hi,
I am using this to refer to the MdiParent:
BrowsePatientForm.MdiParent = this;
is it possible to to refer to specific form instead so it will be something like this:
BrowsePatientForm.MdiParent = frmMain;
|
|
|
|
|
jrahma wrote: is it possible to to refer to specific form instead
Yes it is.
|
|
|
|
|
but I am getting this when I try:
Error 13
|
|
|
|
|
You have to have an instance of frmMain before you can actually use it like this. You can't just give it a type name and hope that it knows how to handle this - what would happen, for example, if you have two instances of frmMain?
|
|
|
|
|
As Pete O'Hanlon has already said, you need to assign it an instance of your form.
Typically in an app, there would be only one MDI Form (although .NET allows you to have more than one). You instantiate it at the start of your program and hold a reference to the instance in a static field somewhere.
Alternatively, you can also make your MDI Form a Singelton.
|
|
|
|
|
So long as variable frmMain is the correct instance of the MDI child form, then yes, its ok.
|
|
|
|
|
|
Hi All,
Please help me to know what is the best controls for windows applications from this features:
* Performance.
* Support right to left languages.
such as telerik, infragistics,..etc
thanks all
|
|
|
|
|
For right to left languages, you can use standard MS controls.
All you need to do is configure the appropriate language in the OS e.g. here[^].
|
|
|
|
|
HI,
But the MS Controls specially grid, doesn't have a grouping, filtering, summarizing, export to excel features.
Are There Another Control?
|
|
|
|
|
|
They all have trial versions available. Rather than getting the opinion of someone else, who might have different criteria for judging these things, why not trial the different versions yourself, and pick the one that best fits your needs and price requirements?
|
|
|
|
|
HI,
I try a trial versions but most of them doesn't support r-t-l languages.
|
|
|
|
|
|
Hi,
I have this code below that is not working like i want it to and has no errors when i debug. I want it to display a member values in respective textboxes that are in a table called 'addpeople' by a click of a button AFTER i key in the member ID of a member.
Text boxes are like;
Title
member ID
First name
Last Name
Address 1
Address 2
....
...
...
Email..
Here is the code:
private void btnView_Click(object sender, EventArgs e)
{
string input = cmbMemberId.Text;
string conn = "server=localhost;user=root;password='';database=m_chama;";
MySqlConnection myconn = new MySqlConnection(conn);
string sql = "SELECT * FROM addmember WHERE Member_ID = '" + input + "';";
MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count == 0)
{
MessageBox.Show("No data found.", "Not Exists");
}
else
{
foreach (DataRow dr in dt.Rows)
{
if (dr[0] + "" == input)
{
txtFirstName.Text = dr[0] + "";
break;
}
}
}
}
|
|
|
|
|
Try debugging and stepping through your code and figure out if your query is returning correct data.
If you are able to go into the else part of your code, check if there are any valid values inside dr[0].
After that you need to populate your textboxes, so you will need code like
foreach (DataRow dr in dt.Rows)
{
if (dr[0] + "" == input)
{
txtFirstName.Text = dr[0] + "";
break;
}
txtLastName = dr[1];
txtTitle = dr[2];
}
where the indexes need to match the appropriate values.
|
|
|
|
|
There are two important things to do here:
1) Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead:
string sql = "SELECT * FROM addmember WHERE Member_ID = @ID;";
MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn);
da.SelectCommand.Parameters.AddWithValue("@ID", input);
2) Don't use "*" as the column list in an sql command - particularly if you are going to use numeric indexes. Not only do they make your code liable to fail if the external database is changed, but the order in which SQL returns columns is not defined - when you specify "*" as the columns list SQL is at liberty to return them in any order it desires. Normally it returns them in definition order - but it doesn't have to, and there is no guarantee that future versions will do so. Name your columns in the SELECT (preferred, as it reduces the data returned to just the columns you want), and / or use names for the DataRow index.
Implementing these may solve your problem, but you also should not add an empty sting onto the dataRow - it looks silly and is unnecessary. cast it to a string instead:
foreach (DataRow dr in dt.Rows)
{
string iD = (string) dr["iD"];
if ((string) dr["iD"] == input)
{
txtFirstName.Text = (string) dr["FirstName"];
break;
}
}
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Thank you guyz,
You gave me ideas and it worked.
This is the code that worked...
private void btnView_Click(object sender, EventArgs e)
{
string input = cmbMemberId.Text;
string conn = "server=[servername];user=[username];password=[userpassword];database=[databasename];";
MySqlConnection myconn = new MySqlConnection(conn);
string sql = "SELECT Member_ID, First_Name, ...., ......, ....., ....., ...., EMAIL FROM addmember WHERE Member_ID = @ID;";
MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn);
da.SelectCommand.Parameters.AddWithValue("@ID", input);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count == 0)
{
MessageBox.Show("No data found.", "Not Exists");
}
else
{
foreach (DataRow dr in dt.Rows)
{
if (dr[0] + "" == input)
{
cmbMemberId.Text = dr[0] + "";
txtFirstName.Text = dr[1].ToString();
.....
.....
.....
.....
....
....
txtEmail.Text = dr[8].ToString();
break;
}
}
}
}
Thank you soo much.
|
|
|
|
|
You're welcome!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|