Good day!
Here is my problem: I need to have a radiobutton column in my DataGrid for a
representation of a bool column, where only row can be checked at one
time(only one value in bool column can be true). So I've created a class
inheriting from DataGridColumnS tyle and added the following code to the class:
protected RadioButton [] rb ;
....
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
Rectangle rect = bounds;
g.FillRectangle (backBrush,rect );
if(Convert.ToBo olean(GetColumn ValueAtRow(sour ce, rowNum)))
rb[rowNum].Checked = true;
else
rb[rowNum].Checked = false;
rb[rowNum].Bounds = new Rectangle
(bounds.X + 2, bounds.Y + 2,
bounds.Width - 4, bounds.Height - 4);
}
protected override void SetDataGridInCo lumn(DataGrid value)
{
base.SetDataGri dInColumn(value );
if(value != null)
{
if(value.DataSo urce!=null)
{
CurrencyManager source =
(CurrencyManage r)value.Binding Context[value.DataSourc e];
rb = new RadioButton[source.Count];
for(int i=0;i<source.Co unt;i++)
{
rb[i] = new RadioButton();
rb[i].Visible = true;
rb[i].CheckedChanged +=new EventHandler(Ra dioButtonValueC hanged);
value.Controls. Add(rb[i]);
}
}
}
}
private void RadioButtonValu eChanged(object sender, EventArgs e)
{
RadioButton rb1 = (RadioButton)se nder;
CurrencyManager source =
(CurrencyManage r)((DataGrid)rb 1.Parent).Bindi ngContext[((DataGrid)rb1. Parent).DataSou rce];
for(int i=0; i< source.Count; i++)
{
source.Position = i;
if(rb1.Equals(r b[i]))
SetColumnValueA tRow(source, i , true);
else
SetColumnValueA tRow(source, i, false);
}
}
So here I've faced some problems:
1. when I sort the datagrid, the checked radiobutton doesn't change it's
positions, seems like CurrencyManager stays the same.
2. when I use dataview with some rowfilter as a source for my datagrid,
checking radiobutton constanly throws Out of Index exception.
3. do I really have to change source.position in cycle(otherwise , it
throws an exception)?
Thanks in advance. 1 4037
Found out solutions to most of my problems, except for one: after I click on
the column header of DatGrid control, Sort property of the DataView I'm using
as a source for a DataGrid doesn't seem to change :( This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill C. |
last post by:
Hello,
I know this has been discussed a lot already because I've been searching
around for information the last few weeks.
I'm trying to implement a DataGridComboBoxColumn class. I've found
several examples on the web. They all seem to have problems, though
that I've been unable to resolve.
The most promising example I have found is at:
|
by: Raj |
last post by:
Hi,
When we are sorting the DataGrid Boolean column the grid is becoming
redcross.
I have my own PPMIPDataGridBoolColumn class inherited from
System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one
DataGridValueChangedEventHandler event handler. I am overriding Edit() to
know the current state of the cell. I am overriding Paint() to know the if
the user has been editing the cell. I am also overriding the Commit() to
|
by: dave |
last post by:
I have half a dozen web form radio buttons on a web form. Each of them is set to postback=true. However, if for instance radiobutton1 is already selected and the user selects it again, it performs a postback.
I only want to do a postback if the value of the radiobutton is changed.
What is the best method to accomplish this?
thx
dave
|
by: Doug Bell |
last post by:
Hi,
Can you lock the colum in a datagrid so that it can not be resized by th
user?
Thanks Doug
|
by: Agnes |
last post by:
I understand it is impossible, but still curious to know "Can I freeze
several column in the datagrid, the user can only scroll the first 3 columns
(not verical), for the rest of the coulumn, it is freeze.
| |
by: Aaron Smith |
last post by:
Is there a way to put a limit on the text size of a datagrid column?
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
|
by: Geroge D. Lake |
last post by:
Hi,
I need to disable the resizing of a datagrid.
I have tried al day and no luck.
Any Ideas?
Thanks.
George.
|
by: savvy |
last post by:
I have used MetaBuilders.WebControls for including a radiobutton in a
datagrid. Its works fine with retreiving the checked radiobutton
datagrid row id. but i'm not able to preselect the row radiobutton
which matches with the database data. ok
I have a Datagrid which displays CV details created by a candidate. So
i want him to make only one of his CVs as a default one. Therefore i
included a radiobutton column which selects the particular...
|
by: Kevin Humphreys |
last post by:
Hi,
Is is possible to to add a new column to an Windows app unbound datagrid
where I can place a radiobutton control?
What I am trying to do is to have a radio button for each row on the
datagrid and have one of the radio button to be checked to treat this row as
the primary row ot the recordset.
VB.NET Code preferrably.
Thanks In Advance,
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: 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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |