You misunderstood me, I didn't mean that you can directly connect Excel with a DataGridView somehow.
But since you already have some code for accessing the table in the Word document, as I've seen from your reply to OriginalGriff, don't mind my answer and follow his advice: Run it in the debugger and analyze what's working and what's not.
I have a trackbar control that is adjusting the brightness of the background color of a form. Eventually, I'll modify it to adjust an image's brightness. If you look at how the brightness slider works in the colorDialog Control, as you move up and down, the value changes from white to black, but in the middle, the hue of the original color is never lost. The problem with my code is that once I reach the high end of brightness (white), or the low end (black), I lose the hue, and the trackbar becomes an adjustment of grayscale brightness, instead of an adjustment of the original color's brightness. So, I need to know how to change my code to adjust the brightness while preserving the hue.
int valueOne = 0, valueTwo = 0, valueNew = 0;
bool count = true;
privatevoid Form1_BackColorChanged(object sender, EventArgs e)
// set inital trackbar position, do this only once, when user sets a new BG color
if (count == true)
trackBar1.Value = (this.BackColor.R + this.BackColor.G + this.BackColor.B) / 3;
count = false;
// Get initial trackbar position value
valueOne = trackBar1.Value;
privatevoid trackBar1_Scroll(object sender, EventArgs e)
int bgRed = 0, bgGreen = 0, bgBlue = 0;
// get amount of change in trackbar value
valueTwo = trackBar1.Value;
valueNew = valueTwo - valueOne;
// apply change amount to original color value
bgRed = this.BackColor.R + valueNew;
bgGreen = this.BackColor.G + valueNew;
bgBlue = this.BackColor.B + valueNew;
// dont allow > 255
if (bgRed > 255)
bgRed = 255;
if (bgGreen > 255)
bgGreen = 255;
if (bgBlue > 255)
bgBlue = 255;
// dont allow < 0
if (bgRed < 0)
bgRed = 0;
if (bgGreen < 0)
bgGreen = 0;
if (bgBlue < 0)
bgBlue = 0;
// apply new settings to form
this.BackColor = Color.FromArgb(255, bgRed, bgGreen, bgBlue);
Don't use the current BackColor as input for the calculation of the new BackColor. Store the initial BackColor in some additional variable that will never be changed and use that one as input for the calculation of the new BackColor. To adjust for that, don't use the the slider delta but the absolute slider value to calculate the new BackColor.
Currently you do:
BackColor -> apply slider delta -> new BackColor v
InitialBackColor -> apply slider position -> current BackColor
I appreciate the reply. I'm sorry, but I'm really not understanding what you're getting at. Could you provide more details, or perhaps some sample code?
EDIT: To expand on that, one thing I don't understand is what I do with that initial value. Let's suppose I put it in three int variables, int R, G, and B. If I add that to the absolute value of the trackbar, in many cases, the result will be over 255, since I'm using the absolute value of the trackbar instead of the delta. The code will be adjusting this to 255. But this will be resulting in a lot of white results. Which makes me wonder if I'm understanding correctly.
Let's assume an initial background color of RGB 20/50/150.
1) Determine the color component with the smallest value and subtract it from 255. In this case: (Red) 255-20 = 235
2) Determine the color component with the highest value. In this case: (Blue) 150
3) Set the Maximum of the TrackBar to the sum of those values: 235+150 = 385
4) Set the Value (Position) of the TrackBar to the value from Step 2: 150
5) When the slider gets moved, take its Value and subtract the value from Step 2. Add the result of this to the color components of the initial background color (with Min/Max of 0/255 of course) and set it as current background color.
Let's assume the TrackBar got moved to 0. Then we calculate: 0-150 = -150
R: 20 + -150 = -130 ==> 0
G: 50 + -150 = -100 ==> 0
B: 150+ -150 = 0
Let's assume the TrackBar got moved to 200. Then we calculate: 200-150 = 50
R: 20 + 50 = 70
G: 50 + 50 = 100
B: 150+ 50 = 200
Let's assume the TrackBar got moved to 385. Then we calculate: 385-150 = 235
R: 20 + 235 = 255
G: 50 + 235 = 285 ==> 255
B: 150+ 235 = 385 ==> 255
Edit: If you want to achieve that all three color components reach the min/max value "at the same time" so that no value has to be "clipped" (which will probably produce a better result for image brightness adjustment) you would have to apply some slightly more sophisticated math but I think you'll get the basic idea from the above method.
I've made the Tic Tac Toe game.
Now I also added the "Multiplayer" function (LAN - TCP - UDP).
My problem is after I created the Multiplayer menutoolstrip and the dialog for the connection, I have some problems to link it up to the game.
Here is my code:
public partial class Multiplayer : Form
EndPoint epLocal, epRemote;
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
public class DownloadPDFController : ApiController
public static string ConnectionString = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
FabcoDBDataContext _ObjDb = new FabcoDBDataContext(ConnectionString);
public HttpResponseMessage Get()
string FN = Directory.GetFiles(@"C:\XXX");
SqlConnection connection = new SqlConnection(ConnectionString);
string query = "select * from XXX where convert(datetime,convert(varchar(10),last_update,101))=convert(datetime,convert(varchar(10),'2015-03-19',101))";
SqlCommand Command = new SqlCommand(query, connection);
SqlDataAdapter da = new SqlDataAdapter(Command);
DataSet ds = new DataSet();
if (ds.Tables.Rows.Count > 0)
MemoryStream responseStream = new MemoryStream();
bool fullContent = true;
var fName = string.Empty;
for (int i = 0; i <=ds.Tables.Rows.Count; i++)
fName = ds.Tables.Rows[i].ToString();
var DataFlag = ds.Tables.Rows[i].ToString();
string aa = "C:\\Fabco";
//string fName = "jQueryNotes.pdf";
var filepath = aa + "/" + fName;
If you want two separate downloads you'll need to make two requests. One technique for doing this is to show the user a page that has two hidden iframes and the src of the iframe is the url of your page that pushes the file to the user.
Hello there. I am trying to implement tree node mouse double click event along with context menu strip. Problem is: I have to click three times, in order to get the functionality of node double click. Skeleton of the program is as follows
// Node Double click event
privatevoid tree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
// task one here
// Mouse Down
privatevoid tree_MouseDown(object sender, MouseEventArgs e)
if (e.Button == System.Windows.Forms.MouseButtons.Left)
// task two here
What should be done here.... so that I don't have to click three times for the NodeMouseDoubleClick event. Thanks for any input.
My .Net application has registered with a particular table using SQLDependency for change events . Once the table content is changed, .Net application should be notified.
This happens correctly except on Hyper V machines.
Also, for this issue to happen, "Use sharing Wizard" option should be checked in "View" tab of "Organize\Folder Options" in Windows Explorer
I checked the broker Service and is enabled.
Also, the sys.transmission_queue table which contains any error message in case messages are not delivered is empty.
Any suggestion in this regard would be appreciated.
Thanks in advance.