| |

VerySource

 Forgot password?
 Register
Search
View: 959|Reply: 7

Why ccc = dataGrid1.TableStyles ["temp_1"]; returns an empty object

[Copy link]

2

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-15 13:30:01
| Show all posts |Read mode
dataGrid1.DataSource = temp_1; bound data source dataGrid displays normally
DataGridTableStyle ccc = new DataGridTableStyle ();
ccc = dataGrid1.TableStyles ["temp_1"]; Get TableStyles object of dataGrid1
Why can't I get the TableStyles object when the screen has displayed data?
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-4-16 16:15:01
| Show all posts
When TABLESTYLES.COUNT in DATAGRID is greater than 0, the style sheet exists. Similarly, you can also determine the value of GridColumnStyles.Count. Just set the DataSource. Although it can be displayed, it cannot refer to its TableStyle.
   Create TableStyle at design time, or execute a sentence:
   TableStyle ts = new TableStyle ();
   DataGrid1.TableStyles.add (ts);
Reply

Use magic Report

0

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-16 20:45:01
| Show all posts
You didn't add DataGridTableStyle to DataGrid first and then bind, if you want to get this DataGridTableStyle
Can be as follows
DataGridTableStyle tabs = new DataGridTableStyle ();
DataGridColumnStyle style = new DataGridColumnStyle ();
tabs.GridColumnStyles.Add (style);
tabs.MappingName = temp_1;
dataGrid1.TableStyles.Add (tabs);

DataGridTableStyle ccc = dataGrid1.TableStyles ["temp_1"]
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-4-19 18:30:01
| Show all posts
By default, the collection returned by the TableStyles property does not contain any DataGridTableStyle objects.

See MSDN for details:

ms-help: //MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.NETDEVFX.v20.chs/CPref17/html/P_System_Windows_Forms_DataGrid_TableStyles.htm
Reply

Use magic Report

0

Threads

17

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-20 17:15:01
| Show all posts
The value of the TableStyles property must be set first.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-24 16:00:01
| Show all posts
Before binding, you should add a DataGridTableStyle
Reply

Use magic Report

0

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Unknown

Post time: 2020-4-28 02:00:01
| Show all posts
Object must be defined first
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-8-17 14:45:01
| Show all posts
First read into an array, then remove from the array
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list