I have been on newsgroup for week. I have seen anything that will help me. Basically, I have a form with a datagrid that can be sorted or unsorted (it is up to the user). Then, I display the data of the selected row in textboxes on dialog that execute by the user press a button. The following code works if I do not sort the datagrid before I press the button to bring up the dialog. It is when I sort it the datagrid I have the issue
private void Frm_CustomerAU_ Load(object sender, System.EventArg s e
Frm_Customers frmCustomers= (Frm_Customers) this.Owner;
CurrencyManager currencyMgr = (CurrencyManage r)this.BindingC ontext[frmCustomers.ta bleInfoDG.DataS ource, "Table"]
currencyMgr.Pos ition = frmCustomers.ta bleInfoDG.Curre ntRowIndex
DataRow currentRow = ((DataRowView)c urrencyMgr.Curr ent).Row
txtBxCompanyNam e.Text= currentRow["CompanyNam e"].ToString()
I have also tried using the following code to bind the table to the textbox and I get the same result
txtBxCompanyNam e.DataBindings. Add("Text", frmCustomers.ta bleInfoDG.DataS ource, "Table.CompanyN ame")
I believe it has something to do what I am setting CurrencyManager position to ( currencyMgr.Pos ition = frmCustomers.ta bleInfoDG.Curre ntRowIndex;). I know I need it to be the position of the underlying table in order to get the selected position in the datagrid. I just do not know how to get the position. By the way, this is C
Any help would be greatly appreciated 1 2418
Try PropertyManager .
private void Current_Changed (object sender, EventArgs e)
{
BindingManagerB ase bm = (BindingManager Base) sender;
/* Check the type of the Current object. If it is not a
DataRowView, exit the method. */
if(bm.Current.G etType() != typeof(DataRowV iew)) return;
// Otherwise, print the value of the column named "CustName".
DataRowView drv = (DataRowView) bm.Current;
Console.Write(" CurrentChanged) : ");
Console.Write(d rv["CustName"]);
Console.WriteLi ne();
}
--
=============== =============== =============== ========
* ÃλÃÈçÕ棡 ¡¡¡¡*
* ÎÒºÜÕæ³Ï£¬µ«ÎÒÉ ú»îÔÚ»ÑÑÔÖ®ÖС£ ¡¡¡¡*
* ¡¡¡¡*
* ÎÒÅ×ÆúÁËËùÓеÄÓ ÇÉËÓëÒÉÂÇ£¬È¥×· ÖðÄÇÎ޼ҵij±Ë®£ ¬ *
* ÖÕÓÚÕÒµ½ÁËÒ»¸ö° ®ÎÒµÄÅ®ÈË£¬´Ó´Ë ʧȥÁË×ÔÓÉ£¡ ¡¡ *
*[csharp] °ßÖñ ÌÀ½¨¾ü ¡¡ ¡¡*
=============== =============== =============== ========
"kll" <an*******@disc ussions.microso ft.com> дÈëÏûÏ¢
news:60******** *************** ***********@mic rosoft.com... I have been on newsgroup for week. I have seen anything that will help
me. Basically, I have a form with a datagrid that can be sorted or unsorted
(it is up to the user). Then, I display the data of the selected row in
textboxes on dialog that execute by the user press a button. The following
code works if I do not sort the datagrid before I press the button to bring
up the dialog. It is when I sort it the datagrid I have the issue. private void Frm_CustomerAU_ Load(object sender, System.EventArg s e) { Frm_Customers frmCustomers= (Frm_Customers) this.Owner;
CurrencyManager currencyMgr =
(CurrencyManage r)this.BindingC ontext[frmCustomers.ta bleInfoDG.DataS ource,
"Table"]; currencyMgr.Pos ition = frmCustomers.ta bleInfoDG.Curre ntRowIndex;
DataRow currentRow = ((DataRowView)c urrencyMgr.Curr ent).Row;
txtBxCompanyNam e.Text= currentRow["CompanyNam e"].ToString(); } I have also tried using the following code to bind the table to the
textbox and I get the same results txtBxCompanyNam e.DataBindings. Add("Text",
frmCustomers.ta bleInfoDG.DataS ource, "Table.CompanyN ame"); I believe it has something to do what I am setting CurrencyManager
position to ( currencyMgr.Pos ition =
frmCustomers.ta bleInfoDG.Curre ntRowIndex;). I know I need it to be the
position of the underlying table in order to get the selected position in
the datagrid. I just do not know how to get the position. By the way, this
is C# Any help would be greatly appreciated. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: pcPirate |
last post by:
Hi,
I have a few questions regarding the C# Datagrid
i) I've customised a datagrid with 2 textboxButton (Column1) (Column2) in
it. (It's a control with combination of Textbox with a small button in it)
ii) Once I click the button, it would show a dialog box. The dialog box has
a listview with two column.
iii) After I selected an item from the dialog box's listview, the Column1
would display the listview's first column item, and the...
|
by: Empire City |
last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a
RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a
ListItem in the cell. The display part works fine. I then check some boxes
and hit the submit button. I can't seem to get the value that is selected on
the RadioButton List. I don't want to use the EditTemplate thing I just want
to click on the radiobutton and submit the form. I also don't want to do...
|
by: Doug |
last post by:
Hi
I have the following code (not mine) that populates a datagrid with some
file names. But I want to replace the datagrid with a combo box.
private void OnCurrentDataCellChanged(object sender, System.EventArgs e)
{try{
DataSet ds = dgMembers.DataSource as DataSet;
|
by: Alpha |
last post by:
I have a window application. In one of the form, a datagrid has a dataview
as its datasource. Initial filtering result would give the datavew 3 items.
When I double click on the datagrid to edit the selected lie item at which
case I would pop up a separate dialog box to do so, in the debugging code,
the dataview.count would return 0. I get a error message because I tried to
get values out of a dataview that holds 0 items. Does anyone...
|
by: Empire City |
last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a
RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a
ListItem in the cell. The display part works fine. I then check some boxes
and hit the submit button. I can't seem to get the value that is selected on
the RadioButton List. I don't want to use the EditTemplate thing I just want
to click on the radiobutton and submit the form. I also don't want to do...
| |
by: Jason |
last post by:
I've been trying to figure out a good way to do this but haven't had much
luck, any input would be greatly appreciated.
Basically, after a datagrid is sorted, how can I get the primary key value
of the item selected by the user? That is, not the datagrid index
'location' of the item the user selected, but the value inside a column of
this item the user clicked on.
I would use the CurrencyManager in a windows application but I'm not...
|
by: Bob Hollness |
last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the
questions I may ask!
I have a datagrid which I have populated from a database. It works great!
I have added a column, via the Columns dialog box from the properties of the
datagrid, on the left that contains a select button. So now, when you press
the button the whole row is highlighted.
Now, what I want to do is have the user highlight as many rows as they wish...
|
by: Adda |
last post by:
I have a datagrid on a parent mdi form with connection1,
dataAdapter1, dataset1. From a main menu I call a child
form where I enter new data and update dataset1 with
dataAdapter2, connection2 on the child form, but the same
dataset (dataset1). The data is stored in a sql server DB
and is being stored correctly, but the new record is not
being displayed in the datagrid on the parent form. If I
close the app and re-open it, I can see the...
|
by: Brian Tkatch |
last post by:
I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next second DataGrid's
DataSource. All that works very well. And, when there are no records to
display, it is simply left blank.
My issue is that when i scroll the first one, sometimes the second grid
shows a bunch of null values (a "new" record).
...
|
by: SanjayKumarDey |
last post by:
I have a vb.net datagrid bound to a dataview on a windows form. I want to
use the datagrid to display and filter a list of items , but since the data
is complex, I don't want the user to edit the item using the datagrid. I'd
like to have another form display when the user double clicks the desired
row in the datagrid, and have that form display details for the selected
datagrid row.
I'm having problems figuring out the best way to pass...
|
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...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |