473,729 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Windows. Forms.DataGrid

hi all, hope some one can help

iv created a datagrid that points to a DataView. the data view takes in a
DataTable. The DataTable then adds the columns using DataColumn.

All fine so far.

The table is set up and i can add stuff to it (text).

however i had made it so that u can't change the text wtih in the table,
which is what i want, but it still lets u select the text.

I want to make it so i just click on a row and all it does is select that
row. iv made is so that when u click on a row it does select that row, but
if u click again it slects the text with in that cells.

Idealy what i want to do is right click on any row, when i do that it
selects that row and pops up a menu that will allow we to remove that row
from the table. Im not worried about the pop up menu at the moment though
as i can't even get it to select a row when i right click and i need to stop
it selecting the text.

Can any one help me plz ? iv seen this possible in other programs but i
assume they use another programing language.

thx scott
Nov 16 '05 #1
3 2402
Hi Scott,

If i undertood you right, you want to make the cells in a datagrid not
editable. The best way to do this is to create a custom
TextBoxColumnSt yle (i'm not sure, search msdn) for every column. When
deriving the new class, you need to override only the OnEdit method
with an empty one. This method is called when the cell receives an edit
request.

To select the row on click and right click implement an event handler
for the OnMouseDown event of the datagrid. The handler should call the
Select(rowNr) method of the datagrid.
For a contextual menu, create a contextmenu on the form, then assign
its name to the contextmenu property of the datagrid.

Hope this helps,
Diablo
scott wrote:
hi all, hope some one can help

iv created a datagrid that points to a DataView. the data view takes in a DataTable. The DataTable then adds the columns using DataColumn.

All fine so far.

The table is set up and i can add stuff to it (text).

however i had made it so that u can't change the text wtih in the table, which is what i want, but it still lets u select the text.

I want to make it so i just click on a row and all it does is select that row. iv made is so that when u click on a row it does select that row, but if u click again it slects the text with in that cells.

Idealy what i want to do is right click on any row, when i do that it
selects that row and pops up a menu that will allow we to remove that row from the table. Im not worried about the pop up menu at the moment though as i can't even get it to select a row when i right click and i need to stop it selecting the text.

Can any one help me plz ? iv seen this possible in other programs but i assume they use another programing language.

thx scott


Nov 16 '05 #2
Scott,

Build you table style using the following datagridtextbox column. It will
select the entire row and not enter the individual columns.
private class DataGridNoActiv eCellColumn : DataGridTextBox Column
{
protected override void Edit(System.Win dows.Forms.Curr encyManager
source, int rowNum, System.Drawing. Rectangle bounds, bool readOnly,
string
instantText, bool cellIsVisible)
{
this.DataGridTa bleStyle.DataGr id.Select(rowNu m);
}
}


"scott" <sc***********@ hotmail.com> wrote in message
news:ct******** **@newsg4.svr.p ol.co.uk...
hi all, hope some one can help

iv created a datagrid that points to a DataView. the data view takes in a
DataTable. The DataTable then adds the columns using DataColumn.

All fine so far.

The table is set up and i can add stuff to it (text).

however i had made it so that u can't change the text wtih in the table,
which is what i want, but it still lets u select the text.

I want to make it so i just click on a row and all it does is select that
row. iv made is so that when u click on a row it does select that row, but
if u click again it slects the text with in that cells.

Idealy what i want to do is right click on any row, when i do that it
selects that row and pops up a menu that will allow we to remove that row
from the table. Im not worried about the pop up menu at the moment though
as i can't even get it to select a row when i right click and i need to
stop
it selecting the text.

Can any one help me plz ? iv seen this possible in other programs but i
assume they use another programing language.

thx scott

Nov 16 '05 #3
If you're trying to select a row with the right mousebutton you could use
code like this I guess:

private void dataGrid1_Mouse Up(object sender,
System.Windows. Forms.MouseEven tArgs e)
{
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = dataGrid1.HitTe st(pt);
if(hti.Type == DataGrid.HitTes tType.Cell)
{
dataGrid1.Curre ntCell = new DataGridCell(ht i.Row, hti.Column);
dataGrid1.Selec t(hti.Row);
}
}

You can find this code on:
http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q689q
It works fine for the left mousebutton, but you'll still have to do some
work with the right button because it seems that the text in the previously
selected row also stays selected.
But hopefully it will help you in the right direction...
"scott" <sc***********@ hotmail.com> schreef in bericht
news:ct******** **@newsg4.svr.p ol.co.uk...
Idealy what i want to do is right click on any row, when i do that it
selects that row and pops up a menu that will allow we to remove that row
from the table. Im not worried about the pop up menu at the moment though
as i can't even get it to select a row when i right click and i need to
stop
it selecting the text.

Nov 16 '05 #4

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

Similar topics

3
9141
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 system.windows.forms.dll
0
1991
by: Victor Crudu | last post by:
Hi, could somebody help me to solve the follwing problem ? I get the following exception when i set as the DataSource of a DataGrid a DataTable. This situation can be only if I change programaticaly the minimum property of the scroll bar to be >0. But i even do not have access to the scroll bars of the grid because the scrollbars are protected. Unhandled Exception:
0
1869
by: sarah | last post by:
Using .NET C# installed Framework 1.1 with Service Pack 1 I have a MDI application in C# that contains 3 different forms. Form 1 has several controls one of which is a DataGrid control that works fine. Form 2 has several controls, none of which ia a DatGrid control. Form 3 has several controls, none of which as a DataGrid. In this configuration everything compiles and runs fine. When I add a DataGrid control to Form 3 I get the...
3
2153
by: max | last post by:
I can generate this error by NOT assigning a tableName to the view: at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit() Is there any possibility of getting an event from the AddNewRow()? I would like to make some changes to the row prior to the user typing in the DataGrid. Thanks,
5
2077
by: Sanddevil | last post by:
Hi there - I hope someone out there can help me! I'm using a .Net DataGrid Class to show the results of a SQL query in a spreadsheet type control. The code, which works fine is: iRowCount = oleDbDataAdapter1->Fill(dataSet1); dataGrid1->DataSource = dataSet1->Tables->Item->DefaultView;
3
2392
by: mahtan | last post by:
Please help I have the problem that when I change the data in a Windows.Forms.DataGrid by a separate thread the following Exception is thrown: ThreadSystem.NullReferenceException in system.windows.forms.dll I can't catch this Exception and it only occurs when I
1
2115
by: melanieab | last post by:
Hi, I'm have a datagrid, and I'm trying to have a tooltip pop up if a cell has been hovered on for 2 seconds. I was thinking of using DataGrid.Hover, but then decided to try this instead: static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); private void dg_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { System.Timers.Timer timer = new System.Timers.Timer();
3
1097
by: melanieab | last post by:
Hi, I'd been saying DataGrid.HitTestInfo HitInfo = dg.HitTest(e.X, e.Y); for a while without any problem (of course with using System.Windows.Forms;). Then suddently I got errors and had to add System.Windows.Forms. in front of DataGrid.HitTestInfo. Just wondering if anyone knew of possible reasons for this. Thanks! Melanie
1
2795
by: Rajesh Kumar Choudhary | last post by:
Hi, I want to use the system.windows.form.datagrid control present in .net 2005 or 2003. Is it possible to use this? Please let me know if it is not supported. I have seen and used the classes from FCL using system.tlb or mscorelib.tlb from dot net framework. I could use ArrayList successfully without any issue.
0
1976
by: Mike | last post by:
Hi, I have a collection object bound to a data grid, after I remove an item from the collection, the minute I click on the datagrid I get an error saying the specified argument was out of the range of valid values. After I remove the element from the collection I clear the databindings from the data grid and rebind it but as far as I can tell the collection seems to be the right size but for some reason when I
0
8927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8764
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9289
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9156
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8159
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4798
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3242
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.