C# :: DataGridView - Context Menu To Show Up When User Right Clicks On Fifth Column
May 22, 2014
I have a datagridview with many columns. I want a context menu to show up when user right-clicks on the fifth column (column index = 4).
private void dgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
DataGridView.HitTestInfo hit = dgv.HitTest(e.X, e.Y);
if (hit.ColumnIndex == 4) {
contextMenuStrip1.Show(Cursor.Position);
}
}
}
The problem is, the hit.ColumnIndex value is either 0, -1 or 1, no matter where I click. So the condition never met and the context menu never shows up. Why the values 0, -1 or 1?
View 3 Replies
ADVERTISEMENT
Feb 29, 2012
To add my program into the context menu (when the user right click on excel file). I used the following code:
Code:
public static bool AddContextMenuItem(string Extension, string MenuName, string MenuDescription, string MenuCommand)
{
bool ret = false;
RegistryKey rkey = Registry.ClassesRoot.OpenSubKey(Extension);
if (rkey != null)
{
string extstring = rkey.GetValue("").ToString();
[Code] .....
I used the following function to retrieve the excel file path has been rightclick choose to load the program:
Code:
public static void OpenExcelFileWithEasyForm(string filePath)
{
try
{
string excelFilePath = Path.Combine(Path.GetDirectoryName(filePath), string.Format("{0} (EasyForm){1}", Path.GetFileNameWithoutExtension(filePath), Path.GetExtension(filePath)));
[Code] .....
But I still do not load the excel file into my program by selecting the program from ContextMenu (right click on excel file and choose program). Although if select the path to excel file from the program, the data from excel file is loaded into the program.
I'm still missing something at function OpenExcelFileWithEasyForm(). How to complete this function to load the excel file into my program when selecting programs in ContextMenu.
View 1 Replies
View Related
Sep 7, 2014
how to create a context menu but none of them discuss how to actually fetch the selected menu item?
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add(new MenuItem("Font Size 8"));
m.MenuItems.Add(new MenuItem("Font Size 9"));
m.MenuItems.Add(new MenuItem("Font Size 10"));
m.Show(listBoxChecklist, new Point(e.X, e.Y));
//tempString = m.?????
}
View 3 Replies
View Related
Jan 5, 2014
I'm trying to build an app, but i don't know which is the best language choice. For starters, the app should be able to:
1. run from context menu
2. when selecting some text from a web browser (ff, ie), that text is captured (preferably not in clipboard) and sent as argument to the program via context menu and the program starts executing...
Is this possible?
e.g. [URL] ....
View 2 Replies
View Related
Apr 24, 2014
I cannot check the checkbox in my datagridview.
Here is my code.
First, I added a checkbox column.
private void addCheckBoxColumn() {
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
checkColumn.Name = "clmCheck";
checkColumn.HeaderText = "";
checkColumn.Width = 100;
checkColumn.ReadOnly = false;
dgv1.Columns.Add(checkC
[Code] ....
View 4 Replies
View Related
Apr 18, 2014
I need to take a single column and all the rows in the column from a datagridview to a listbox using a for loop. My code is giving me no errors just not showing any data in the listbox.
private void frmProject6_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'enrollmentsDataSet.Enrollments' table. You can move, or remove it, as needed.
this.enrollmentsTableAdapter.Fill(this.enrollmentsDataSet.Enrollments);
[Code] .....
View 1 Replies
View Related
Aug 28, 2014
I have looked into this and I've also read that I should be able to Config Each column Accordingly.
I'm Currently using this piece of code:
//Change the Headers on the DataGridView2//
dataGridView2.Columns["cashQTY"].HeaderText = "QTY";
dataGridView2.Columns["cashDescription"].HeaderText = "DESCRIPTION";
dataGridView2.Columns["cashSupplier"].HeaderText = "SUPPLIER";
[Code] ....
Currently it does not error, but it also does not Show the DateTime in the GridView when running either..
View 2 Replies
View Related
Mar 25, 2014
I have a application that has a tab control and I change the font and color on form load.
But now I need to switch the font and color when I user clicks a button event.
I have 8 of these events, each customized to set different tab font and color.
tabControl1_DrawItem
tabControl1_DrawItem2
tabControl1_DrawItem3
I just do not know how to make this happen.
View 7 Replies
View Related
Apr 12, 2012
When I am filling a Application form and save this Application form Entries in database it saved successfully but below Application form in DataGridView How to show only current Entry row; There is not show a previous Entries in DataGridView?
View 1 Replies
View Related
Mar 14, 2013
I have an MDI application using different menus depending on the current document template in use.
I need to show the top-level File Menu from the IDR_MAINFRAME window when a command is sent from the active document.
I would like to application to deactivate the active child window and then show the File menu as if the alt-F key was pressed from the keyboard.
I have tried CMenu *pMenu=AfxGetMainWnd()->GetMenu();
but this does not display the menu at all.
View 2 Replies
View Related
Apr 15, 2014
I am working on a drink machine simulation. I have a text file that holds the prices, names and inventory. My problem is It won't let me set my prices at 1.00 or higher. Ex: I set the price to 1.50 in the text file then when it reads the info and stores the price it only stores .50 instead of 1.50.
my code:
#include <iostream>
#include <string>
#include <fstream>
[Code].....
View 1 Replies
View Related
Apr 15, 2014
I am working on a drink machine simulation. I have a text file that holds the prices, names and inventory. My problem is It won't let me set my prices at 1.00 or higher. Ex: I set the price to 1.50 in the text file then when it reads the info and stores the price it only stores .50 instead of 1.50.
textfile looks like this:
Apple Juice 1.50 20
Mango Juice 1.50 20
Sprite Mix 1.90 20
Coca Cola 1.90 20
[Code].....
View 2 Replies
View Related
Jul 1, 2014
I have a button click that is adding user input into a datagrid view. I am trying to add the information into a row, but the way I am trying is giving me an error. Is there a better way to do this?
private void submitButton_Click(object sender, EventArgs e)
{
Data_Summary form2 = new Data_Summary();
Data_Summary.Rows.Add(firstNameTxtBox.Text, lastNameTxtBox.Text, phoneNumberTxtBox.Text);
form2.Show();
}
View 4 Replies
View Related
Aug 2, 2014
#include <iostream>
#include <iomanip>
#include <fstream>
[Code]....
i have already tried putting system pause or cin.get after it, but no luck
View 1 Replies
View Related
Feb 6, 2014
#include <stdio.h>
#include <string.h>
#define MAX 1000
main()
{
char text[MAX], c;
int i,s;
[Code]...
I need to edit the code here to make the input by the user show up reversed
puts("
Your reverse input is:");
for(i = length - 1; i >= 0; i--){
printf("%c",text[i]);
}
I know this is not right...
View 4 Replies
View Related
Sep 20, 2013
how to re-prompt a user with a switch statement menu that I prompted them earlier with. There are 4 options and after the user chooses an option the menu is supposed to pop up again unless the user chooses option 4, how do I do this? For reference I'll put up my source code.
Code:
int main(){
int init_bal,choice,balance,investment, donation;
printf("Welcome!
[Code]....
View 2 Replies
View Related
Nov 17, 2014
I have created a generic array-like template to create arrays of different types. Now I need to get user input from a menu about which type of array they are building. I tried having the user enter a number and using that number to pick a string from an array of constant strings. But pretty obviously, that threw a type conversion error. Is there a way to convert the literal string of a type into it's type or refer to a type directly.
Here is the code I need to fit a type into at runtime:
SimpleVector<TYPE> myVect = SimpleVector<TYPE>(dataSize);
View 5 Replies
View Related
Aug 1, 2013
I've read that we can write a program that displays a menu of commands for the user to choose from.We can write some functions that implement these commands, then store pointers to the functions in the array :
Code:
void ( *file_cmd[])(void) = { new_cmd , open_cmd }; // 2 cmd's for simplicity
We can get a similar effect with a switch statement but using an array of function pointers gives us more flexibility since the elements of the array can be changed as the programm is running.
I decided to write an example about this in order to understand better the context, I am facing some problems though :
Code:
#include<stdio.h>
#include<stdlib.h>
typedef void (*p_foo) (int);
void foo(int x);
void foo2(int y);
[Code] .....
The problems are :
Code:
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:25: error: too few arguments to function "*(arr + (long unsigned int)((long unsigned int)i * 8ul))"
View 14 Replies
View Related
Nov 3, 2012
The following program takes user input into two arrays and should then determine how many items are different by comparing them with a loop. The comparison always show zero correct answers.
#include <iostream>
using namespace std;
const int QUESTION = 20;
//class for testing grades
class TestGrader {
[Code] ....
View 4 Replies
View Related
May 1, 2013
Write a user-friendly C++ program that allows a user to select repeatedly an operation to be performed from a displayed menu of actions. The menu includes the following items:
1. Simple Statistics
2. Vector Addition
3. Dot Product
4. Exit
The menu actions are described by the following points:
Simple Statistics: This action includes finding the average, and standard deviation of a list of data items. The option should allow the user to specify the name of a file from which the data are read into an array. All the results of this option are displayed on the screen.
Vector Addition: This action allows the user to enter the name of a file from which two vectors, V1 and V2, of equal size N are read. Accordingly, the two vectors are added, and displayed along with the resultant vector on the screen. Your program should check that the two added vectors are of the same size. Otherwise, the program should display a message and allow the user to make another choice from the menu.
Dot Product: This action is similar to the Vector Addition in terms of input, output, and checking validity of the vector operands.
Exit: This action terminates the program.
Your program should include at least the following functions:
1. A function, called ReadVector(), which reads a vector of any size from a given file name, and returns the vector and its size to the caller. The function prototype is defined as follows:
void ReadVector(double V[], int &size, ifstream infile);
2. A function, called DisplayMenu(), which displays the menu and returns the user’s choice as an integer value between 1 and 4. The function prototype is defined as follows:
int DisplayMenu (void);
3. A function, called VectorAdd(), which performs the addition of two vectors, A and B, and returns the resultant vector, C. The function prototype is defined as follows:
void VectorAdd(const double A[], const double B[], double C[], int size);
The sum of two vectors, A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n, is defined as: C = A + B.
Where, C = (c1, c2, …, cn), and ci = ai + bi, for1 i n .
4. A function, called DotProduct(), which performs the dot product of two vectors, A and B, and returns the result. The function prototype is defined as follows:
void DotProduct(const double A[], const double B[], int size, double &result);
The dot-product of two vectors A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n is defined as
n n
n
i
i i b a ....... b a b a b a B . A
1 1 2 2
1
5. A function, called Simple_Stat(), which finds the maximum, minimum, average, and standard deviation of a list of data items passed to it by a one-dimensional array. The function returns the average and standard deviation values. The function prototype is defined as follows:
void Simple_Stat(const double list[], int size, double &average, double
&std_dev);
View 1 Replies
View Related
May 21, 2013
Writing this code that handles clicks with the left mouse button. But I want to be able to check for clicks within a 200x200 pixel area. Here's what I have:
void EGame::OnLButtonDown(int mX, int mY) {
int ID = mX / 200;
ID = ID + ((mY / 200) * 3);
if(grid[ID] != GRID_TYPE_NONE) {
[Code] .....
Using the width and height of the object, e.g; pX->w is width and pX->h is height ....
How would I check within the 200x200 area with mX and mY?
View 2 Replies
View Related
Jan 21, 2014
I have a direct2d application and I want to be able to detect mouse clicks. One example is, (in my borderless window) I would like to have an X at the top right of the screen, that when clicked would close the window. How can I do something like this?
View 3 Replies
View Related
Sep 14, 2013
I have a game that I'm trying to create but I don't really know how to handle mouse motions yet. I have read the LazyFoo.net lesson 9. And I have too searched around on Google but haven't find any good article for what I want to do
But what I want is to check if the mouse is OVER the START button of the game and if the user has pressed the LEFT mouse button the game should START.
This works when I am hovering over the area there I want the mouse to do something:
Code:
else if (event.type == SDL_MOUSEMOTION)
{
if (event.motion.x == 0)
{
quit = true;
}
}
I do not know how to check this. The START and QUIT button is in the middle of the screen and I don't know how to position the mouse there either.
View 5 Replies
View Related
Aug 19, 2013
I am trying to write a menu program that will be broken down into a series of calls to function for each of the menu items. Two of the menu items will be simple programs which I wrote.
I want two of the functions to run one of the two programs I am trying to include as items in the menu.
So far I am only familiar with variables, loops, if statements, and I just learned how to write functions.
The problem I am have is that I don't quite understand how to write a function that will run one of the two programs. Also I am having a hard time writing the program in away that would allow the user to select the menu items.
View 2 Replies
View Related
Apr 7, 2014
I'm creating a program that is based on a menu system. Basically each menu is its own user-defined function. The problem is at each menu you can input 'b' to go to the previous menu. I just have it call the function of that menu.
However, do the functions need to complete themselves eventually? If I just keep calling functions will I just keep going further and further deeper into ever running functions?
If so how do I avoid this and yet keep the option to go back to a previous menu/function?
View 2 Replies
View Related
Feb 27, 2015
I am new to GUI programming, I am using mono winforms
using System.Windows.Forms;
using System.Drawing;
using System.IO;
[Code]...
I tried sw.WriteLine(this.to.Text); but that did not work
View 4 Replies
View Related