473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

System.Drawing.Color

In code I have set the back color of my forms to one of the
System.Drawing.Color options. Anyway, I would like to make these colors
available to my users and let them chooose one for themselves. I know how to
show the color dialog, but I'd like to make these colors available to my
user's instead. Is there a color dialoog that deals with these?
Dec 30 '07 #1
7 1815
On Dec 30, 5:53 am, Greg <AccessVBA...@newsgroups.nospamwrote:
In code I have set the back color of my forms to one of the
System.Drawing.Color options. Anyway, I would like to make these colors
available to my users and let them chooose one for themselves. I know how to
show the color dialog, but I'd like to make these colors available to my
user's instead. Is there a color dialoog that deals with these?
There's "colorDialog" control in toolbox.
Dec 30 '07 #2
On Dec 30, 5:53 am, Greg <AccessVBA...@newsgroups.nospamwrote:
In code I have set the back color of my forms to one of the
System.Drawing.Color options. Anyway, I would like to make these colors
available to my users and let them chooose one for themselves. I know how to
show the color dialog, but I'd like to make these colors available to my
user's instead. Is there a color dialoog that deals with these?
Addition: Add a button to your form and place this code inside
button1_click event:

If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.BackColor = ColorDialog1.Color
End If
Dec 30 '07 #3
Hi Douglas,

In the Form2 within my sample project, I create a BindingSource instance to
bind to the dataset and datatable, and then bind the TextBox and two
ComboBoxes to the BindingSource instance instead of the dataset. In the
Button1's Click event handler, I call the BindingSource.EndEdit method to
apply the pending changes to the underlying data source and all works well.
The following is the modified code in the Form2:

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private DataSet ds;
public DataSet DS
{
get { return ds; }
set { ds = value; }
}
// create a BindingSource instance
private BindingSource bs;

private void Form2_Load(object sender, EventArgs e)
{
BindingSource bsParent = new BindingSource(ds,"Measure");
BindingSource bsChild =new
BindingSource(bsParent,"Measure_Unit");
this.comboBox1.DataSource = bsParent;
this.comboBox1.DisplayMember ="Name";
this.comboBox1.ValueMember = "ID";

this.comboBox2.DataSource = bsChild;
this.comboBox2.DisplayMember = "Name";
this.comboBox2.ValueMember = "ID";

// bind the BindingSource instance to the dataset
bs = new BindingSource(ds, "DataTable1");

// bind the controls to the BindingSource instead of the dataset
this.textBox1.DataBindings.Add("Text", bs, "ID");
this.comboBox1.DataBindings.Add("SelectedValue", bs,
"MeasureID");
this.comboBox2.DataBindings.Add("SelectedValue", bs, "UnitID");

// call the BindingSource.AddNew method to add a new row
bs.AddNew();
}

private void button1_Click(object sender, EventArgs e)
{
this.comboBox2.DataBindings["SelectedValue"].WriteValue();

// call the BindingSource.EndEdit method to apply the pending
changes to the underlying data source
bs.EndEdit();
this.Close();
}
}

Since I couldn't reproduce the problem in my sample project, I strongly
recommend you to send me a sample project that could just reproduce the
problem or modify my sample project to reproduce the problem.

Thank you for your understanding and I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

Dec 31 '07 #4
Linda,

It looks like you responded by accident to this email rather than the
intended.
"Linda Liu[MSFT]" wrote:
Hi Douglas,

In the Form2 within my sample project, I create a BindingSource instance to
bind to the dataset and datatable, and then bind the TextBox and two
ComboBoxes to the BindingSource instance instead of the dataset. In the
Button1's Click event handler, I call the BindingSource.EndEdit method to
apply the pending changes to the underlying data source and all works well.
The following is the modified code in the Form2:

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private DataSet ds;
public DataSet DS
{
get { return ds; }
set { ds = value; }
}
// create a BindingSource instance
private BindingSource bs;

private void Form2_Load(object sender, EventArgs e)
{
BindingSource bsParent = new BindingSource(ds,"Measure");
BindingSource bsChild =new
BindingSource(bsParent,"Measure_Unit");
this.comboBox1.DataSource = bsParent;
this.comboBox1.DisplayMember ="Name";
this.comboBox1.ValueMember = "ID";

this.comboBox2.DataSource = bsChild;
this.comboBox2.DisplayMember = "Name";
this.comboBox2.ValueMember = "ID";

// bind the BindingSource instance to the dataset
bs = new BindingSource(ds, "DataTable1");

// bind the controls to the BindingSource instead of the dataset
this.textBox1.DataBindings.Add("Text", bs, "ID");
this.comboBox1.DataBindings.Add("SelectedValue", bs,
"MeasureID");
this.comboBox2.DataBindings.Add("SelectedValue", bs, "UnitID");

// call the BindingSource.AddNew method to add a new row
bs.AddNew();
}

private void button1_Click(object sender, EventArgs e)
{
this.comboBox2.DataBindings["SelectedValue"].WriteValue();

// call the BindingSource.EndEdit method to apply the pending
changes to the underlying data source
bs.EndEdit();
this.Close();
}
}

Since I couldn't reproduce the problem in my sample project, I strongly
recommend you to send me a sample project that could just reproduce the
problem or modify my sample project to reproduce the problem.

Thank you for your understanding and I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

Dec 31 '07 #5
Hi Greg,

Sorry for my first reply which is a mistake.

As for your question, my understanding is that you want to show a color
dialog which only contains several specified colors for the user to choose.
If I'm off base, please feel free to let me know.

I find a good color picker sample in the codeproject website:

http://www.codeproject.com/KB/select...lorpicker.aspx

You can use the ColorPanel in the above sample to show the specified colors
for the user in your application.

Hope this is what you want.

If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 31 '07 #6
On Dec 31, 4:49 am, v-l...@online.microsoft.com (Linda Liu[MSFT])
wrote:
Hi Douglas,

In the Form2 within my sample project, I create a BindingSource instance to
bind to the dataset and datatable, and then bind the TextBox and two
ComboBoxes to the BindingSource instance instead of the dataset. In the
Button1's Click event handler, I call the BindingSource.EndEdit method to
apply the pending changes to the underlying data source and all works well.
The following is the modified code in the Form2:

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private DataSet ds;
public DataSet DS
{
get { return ds; }
set { ds = value; }
}
// create a BindingSource instance
private BindingSource bs;

private void Form2_Load(object sender, EventArgs e)
{
BindingSource bsParent = new BindingSource(ds,"Measure");
BindingSource bsChild =new
BindingSource(bsParent,"Measure_Unit");
this.comboBox1.DataSource = bsParent;
this.comboBox1.DisplayMember ="Name";
this.comboBox1.ValueMember = "ID";

this.comboBox2.DataSource = bsChild;
this.comboBox2.DisplayMember = "Name";
this.comboBox2.ValueMember = "ID";

// bind the BindingSource instance to the dataset
bs = new BindingSource(ds, "DataTable1");

// bind the controls to the BindingSource instead of the dataset
this.textBox1.DataBindings.Add("Text", bs, "ID");
this.comboBox1.DataBindings.Add("SelectedValue", bs,
"MeasureID");
this.comboBox2.DataBindings.Add("SelectedValue", bs, "UnitID");

// call the BindingSource.AddNew method to add a new row
bs.AddNew();
}

private void button1_Click(object sender, EventArgs e)
{
this.comboBox2.DataBindings["SelectedValue"].WriteValue();

// call the BindingSource.EndEdit method to apply the pending
changes to the underlying data source
bs.EndEdit();
this.Close();
}
}

Since I couldn't reproduce the problem in my sample project, I strongly
recommend you to send me a sample project that could just reproduce the
problem or modify my sample project to reproduce the problem.

Thank you for your understanding and I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support
Isn't that code a C# code in VB group? And what does differ from
Linda's code when compared to following as i understood from OP:
(nothing mentioned except form backcolor)

Bring colordialog control then:

'To change form backcolor
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.BackColor = ColorDialog1.Color
End If

Regards

Dec 31 '07 #7
Greg,

In my idea is this the only answer in code on your answer.
Tell me what I do see wrong?

\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles
Button1.Click
Dim colDialog As New ColorDialog
If colDialog.ShowDialog() = DialogResult.OK Then
Me.BackColor = colDialog.Color
End If
End Sub
///

Cor

Dec 31 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
1
by: lwickland | last post by:
Summary: System.Net.ScatterGatherBuffers.MemoryChuck allocates inordinately large bytes when sending large post data. The following application consumes inordinate quantities of memory. My code...
3
by: Ladvánszky Károly | last post by:
Although I have added a reference to System.Drawing, the following declaration produces a compile error: System::Drawing::Bitmap* b; // error C2039: 'Drawing' is not a member of 'System' ...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
0
by: Nickneem | last post by:
I' m trying to disable all right mouse clicks by using the vbAccelerator Windows Hooks Library The small (systray / console) app. must catch all (right) mouseclicks before they are received by...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.